Hi,
i have a following problem, concerning the building of means per Recall and ID
ID Recall TotalScore
001 1 4
001 2 2
002 1 4
002 2 0.5
003 1 4
003 2 1
I want to create the means out of the TotalScore for the two Recalls, by every ID; so that it should be like
ID TotalScore_mean
001 3
002 2.25
003 2.5
I thought about the proc means procedure and a class-statement for ID, but it is not working for me.
I would be really happy if someone could help me.
Best,
Nina
proc means data=have mean;
class id;
var totalscore;
run;
proc means data=have mean;
class id;
var totalscore;
run;
Thanks, i just added an output, so I could work with it further. If it helps anyone else:
proc means mean data=have;
class ID;
var TotalScore;
output out=means_totalscore mean=mean_totalscore;
run;
@u58497688 wrote:
Thanks, i just added an output, so I could work with it further. If it helps anyone else:
proc means mean data=have;
class ID;
var TotalScore;
output out=means_totalscore mean=mean_totalscore;
run;
Your output data set will have a variable _type_ indicating combinations of the Class variable. The _type_=0 will be the mean for all the ID values. If you do not want that in the output then add NWAY to the Proc statement to select only the highest type which would have the combinations for the class variable(s) and none of the other summaries. This is actually useful behavior but there is a learning curve about the various options controlling the output with class variables. There will also be a _freq_ variable indicating how many observations were used for each statistic.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.