Hello everyone,
I have a categorical variable, plan_type, that is comprised of 9 levels, A, B, C, D, E, F, G, H, I. I want to combine B and C into a new variable to produce a proc freq table of the statistics. I also want to combine D, E, F, and G into one variable, and H and I into their own variable.
The goal is to produce frequency tables like this using proc freq and tables statements:
Plan Type | |||||||||||
A | B | C | D | E | F | G | H | I | Total | ||
Race/Ethnicity | White | 10 | 5 | 2 | 456 | 156 | 486 | 123 | 4869 | 123 | |
Black | 156 | 8469 | 5468 | 546 | 546 | 86947 | 31 | 84 | 320 | ||
Hispanic | 465 | 486 | 568 | 837 | 195 | 86 | 158 | 963 | 71 | ||
Other | 17 | 752 | 6382 | 5781 | 5714 | 72 | 85 | 185 | 81 | ||
Total |
(the values here are not the values I'm working with and are just an example)
I have tried this code:
data health_data;
set health_data;
if plan_type=('A' 'B')
then variable='A_and_B';
run;
And it returned the error:
You create a custom format, apply it to variable PLAN_TYPE, and then re-run PROC FREQ.
proc format;
value $combf 'B','C'='BC' 'D','E','F','G'='DEFG' 'H','I'='HI';
run;
proc freq;
/* whatever your code was before should go here, plus the following line */
format plan_type $combf.;
run;
You create a custom format, apply it to variable PLAN_TYPE, and then re-run PROC FREQ.
proc format;
value $combf 'B','C'='BC' 'D','E','F','G'='DEFG' 'H','I'='HI';
run;
proc freq;
/* whatever your code was before should go here, plus the following line */
format plan_type $combf.;
run;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.