How to add multiple numeric categories to report the number of observations and percentage of
individuals in each category ?
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 ?
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!
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.
Ready to level-up your skills? Choose your own adventure.