Thursday, October 25, 2007

first. & last.

/* For each family, ped_id starts with 1 */
data pedigree_id;
set family;
by id;
if first.id then ped_id=1;
else ped_id+1;
run;

/* using proc sql */
proc sql;
create table pedigree_id as
select family.*, monotonic() as _n_, calculated _n_-min(calculated _n_)+1 as ped_id
from family
group by id;
quit;

No comments: