BookmarkSubscribeRSS Feed
ccherrub
Obsidian | Level 7

How to add multiple numeric categories to report the number of observations and percentage of
individuals in each category ?

2 REPLIES 2
Reeza
Super User

PROC FREQ and apply a format to your variable. 

 

Or are you asking about when categories overlap?

 

/*This program shows how an multilabel format works and that the summary statistics can be done at a unique level but also aggregated at a higher level included in the data.*/

/*sample data*/
data have;
input Year    Area $    Profit;
cards;
2001    A   1
2002    A   2
2001    B   1
2001    C   3
2002    C   1
2001    E   4
2002    E   2
2001    F   3
2002    F   4
;;;;
run;

*format - groups A/B/C into D and E/F into G as well;
proc format;
value $ area_fmt (multilabel)
'A' = 'A'
'B' = 'B'
'C' = 'C'
'A', 'B', 'C' = 'D'
'E' = 'E'
'F' = 'F'
'E', 'F' = 'G';
run;

*summary statistics - not CLASS and FORMAT statements;
proc means data=have noprint nway;
class year area / mlf;
format area $area_fmt.;
var profit;
output out=want sum(profit)=profit;
run;

*show results;
proc print data=want;
run;

 

Or something like this I'm guessing:

proc format;
value age_fmt
10-12 = 'Pre-Teen'
13 - high = 'Teenager';
run;

proc freq data=sashelp.class;
table age;
format age age_fmt.;
run;

@ccherrub wrote:

How to add multiple numeric categories to report the number of observations and percentage of
individuals in each category ?


 

ccherrub
Obsidian | Level 7
More so like variables (frequency etc) overlapping so just one big chart overall

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 823 views
  • 0 likes
  • 2 in conversation