BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
RandoDando
Pyrite | Level 9

I have data which has already been aggregated like this:

 

Category Groups People
A 23 235
B 45 754
C 12 89

 

And I want something like this (prefer Proc Report for the bells and whistles)

Category Groups Groups Percent People People Percent
A 23 28.8% 235 21.8%
B 45 56.3% 754 69.9%
C 12 15.0% 89 8.3%
Total 80 100.0% 1078 100.0%

 

All the examples I can find online seem to use dis-aggregated data.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

To get multiple statistics from a single variable repeat it with a new column name and then request the statistic:

 

data have;
   input Category $	Groups 	People;
datalines;
A 	23 	235
B 	45 	754
C 	12 	89
;

proc report data=have;
   columns category groups groups=grouppct people people=peoplepct;
   define category /group;
   define groups/ analysis sum;
   define grouppct /analysis pctsum;
   define people/ analysis sum;
   define peoplepct/ analysis pctsum;
run;

However if you want anything that measures dispersion such as standard deviation or range of value you would want to use disaggregated data.

 


@RandoDando wrote:

I have data which has already been aggregated like this:

 

Category Groups People
A 23 235
B 45 754
C 12 89

 

And I want something like this (prefer Proc Report for the bells and whistles)

Category Groups Groups Percent People People Percent
A 23 28.8% 235 21.8%
B 45 56.3% 754 69.9%
C 12 15.0% 89 8.3%
Total 80 100.0% 1078 100.0%

 

All the examples I can find online seem to use dis-aggregated data.


 

 

View solution in original post

3 REPLIES 3
ballardw
Super User

To get multiple statistics from a single variable repeat it with a new column name and then request the statistic:

 

data have;
   input Category $	Groups 	People;
datalines;
A 	23 	235
B 	45 	754
C 	12 	89
;

proc report data=have;
   columns category groups groups=grouppct people people=peoplepct;
   define category /group;
   define groups/ analysis sum;
   define grouppct /analysis pctsum;
   define people/ analysis sum;
   define peoplepct/ analysis pctsum;
run;

However if you want anything that measures dispersion such as standard deviation or range of value you would want to use disaggregated data.

 


@RandoDando wrote:

I have data which has already been aggregated like this:

 

Category Groups People
A 23 235
B 45 754
C 12 89

 

And I want something like this (prefer Proc Report for the bells and whistles)

Category Groups Groups Percent People People Percent
A 23 28.8% 235 21.8%
B 45 56.3% 754 69.9%
C 12 15.0% 89 8.3%
Total 80 100.0% 1078 100.0%

 

All the examples I can find online seem to use dis-aggregated data.


 

 

RandoDando
Pyrite | Level 9

Thanks for that, it worked.  I added the rbreak /summarize statement at the end of this, but I would like to have the label "Total" in that summary row in only the first column.  Is that possible?    I tried this, but obviously, it adds the label in each column.

 

rbreak after/summarize style={pretext="Total"};

 Would also want the label to be indented to the left to align with values in Category.

RandoDando
Pyrite | Level 9

Nevermind.  I got it.

Compute after;
Category = "Total";
endcomp;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 264 views
  • 3 likes
  • 2 in conversation