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

I have the current set of data that looks like this:

IDScorePB
11000.4
2900.6
31200.3
41200.2
5950.15
6850.12
7630.11
81000.19
9520.53
101000.5
111250.23
12900.7

 

I want to summarise it by 'Score' like so:

 

Row LabelsCount of IDAverage of PB

5210.53
6310.11
8510.12
9020.65
9510.15
10030.363333333
12020.25
12510.23

 

How do I go about doing this in SAS? Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
proc summary data=have nway;
    class score;
    var pb;
    output out=stats mean=;
run;
--
Paige Miller

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26
proc summary data=have nway;
    class score;
    var pb;
    output out=stats mean=;
run;
--
Paige Miller
sasprogramming
Quartz | Level 8

This works well thanks, but is there anyway to add a column that is the count, i.e. the frequency of ID?

 

Thanks.

Tom
Super User Tom
Super User

@sasprogramming wrote:

This works well thanks, but is there anyway to add a column that is the count, i.e. the frequency of ID?

 

Thanks.


What is wrong with the count it already produces?

sasprogramming
Quartz | Level 8

Oh I understand now, thank you

novinosrin
Tourmaline | Level 20

Hi @sasprogramming 

The solution provided by @PaigeMiller  should have a variable called _freq_ in the output dataset. I think that's what you are looking for .

You could rename that as count

 

output out=stats (drop=_type_ rename=(_freq_=count)) mean= ;

@sasprogramming wrote:

This works well thanks, but is there anyway to add a column that is the count, i.e. the frequency of ID?

 

Thanks.


 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 737 views
  • 3 likes
  • 4 in conversation