BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
u58497688
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
proc means data=have mean;
    class id;
    var totalscore;
run;
--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26
proc means data=have mean;
    class id;
    var totalscore;
run;
--
Paige Miller
u58497688
Calcite | Level 5

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;

ballardw
Super User

@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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 995 views
  • 0 likes
  • 3 in conversation