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

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