**This code comes from UCLA statistical computing seminar
(link here to code)
proc sort data=kids out=sort_kids;
by famid;
run;
data retain1;
set sort_kids;
retain sumwt count;
/*carry over the value from previous obs to next obs*/
by famid;
if first.famid then do;
/*at 1st obs of each family set sumwt and count = 0*/
sumwt=0;
count=0;
end;
sumwt = sumwt + wt;
count = count + 1;
meanwt = sumwt/count;
run;
proc print data=retain1;
var famid kidname wt sumwt count meanwt;
run;
direct filename with path to a file
13 years ago
5 comments:
Thank you!
thanks for this.
i added
if last.varname then output;
to only grab the total of each variable.
you helped me a lot!
What will be its output look like in saslog???
Faith is taking the first step even when you don't see the whole staircase. See the link below for more info.
#first
www.ufgop.org
Post a Comment