Hi everyone,
I'm having some troubles regarding a procedure using Proc Freq.
I am creating tables based on survey questions that are organized by sex, and would like to combine some of the rows that have similar responses to create more general row labels.
For example:
Question 1: rate your level of satisfaction with your current living arrangement
A) Extremely Dissatisfied
B) Dissatisfied
C) Neutral
D) Satisfied
E) Somewhat Satisfied
I would like a table that combines responses from A and B to create one row being "dissatisfied", and do the same for responses D and E.
I have created my code using proc freq:
proc freq data = work.living;
table '1-Rate your Satisfaction with y'n*'What is your gender?'n / nocum nocol norow;
run;
all data is organize by gender of the respondent.
any help is appreciated!
Thanks!
You don't have to change values in your data to create 3 groups from 5. Instead you can define a FORMAT that collapses values, and tell proc freq to honor that format, as in:
proc format;
value $myfmt 'A','B' = 'AB: disatisfied'
'D','E' = 'DE: satisfied' ;
run;
proc freq data=have;
tables ques1 ques2;
format ques1 ques2 $myfmt.;
run;
I've assumed the actual values in ques1 and ques2 are 'A','B','C','D'; and 'E'. If not change the value statement.
Show us the log so we can see the errors (and the code you used as well). When providing the log, it is critical that you maintain the formatting of the log so we can see it exactly as SAS showed it to you, making it easier for us to use. To maintain the formatting of the log, click on the </> icon and paste the log as text into the window that appears. DO NOT SKIP THIS STEP.
Create a format that combines the values into the same group, and apply the format to the variable in the proc freq.
An example was already provided by @mkeintz
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.