Hi everyone.
My data looks like the one below.
Date ID Trial1 Trial2 Trial3
Feb 1 A 74 71
Feb 10 A 71 72
Mar 5 B 76
Mar 12 C 78
Mar 23 C 79
Mar 30 C 80 80 80
I need to be able to produce an output like the one below showing the total number of trials per ID and average.
ID NTrials Mean
A 4 72
B 1 76
C 5 79.4
Thank you in advance.
Yoyong
A relatively straightforward way:
data temp;
set have;
array trial {3};
do k=1 to 3;
if trial{k} > . then do;
value = trial{k};
output;
end;
end;
run;
proc summary data=temp nway;
var value;
class id;
output out=want (drop=_type_ _freq_) n = NTrials mean = Mean;
run;
A relatively straightforward way:
data temp;
set have;
array trial {3};
do k=1 to 3;
if trial{k} > . then do;
value = trial{k};
output;
end;
end;
run;
proc summary data=temp nway;
var value;
class id;
output out=want (drop=_type_ _freq_) n = NTrials mean = Mean;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.