Hi,
I'm currently working with some stratified survey data and want to run out big tables of one set of responses versus another. i.e. how did individuals that answered question 1 subsequently answer question 2, question 3, question 4 etc.
So far i have got this code running producing exactly what i want in a 'program' sheet within SAS EG:
proc surveyfreq data=QUESTION_DATA_AND_STRATA nosummary;
proc surveyfreq data=QUESTION_DATA_AND_STRATA nosummary;
proc surveyfreq data=QUESTION_DATA_AND_STRATA nosummary;
@nnn123 wrote:
Hi FreelanceReinhard,
Thanks for such a quick response! These codes below create a separate table for each question though. I want them all in one big table if at all possible? There are 22 questions in the survey so it would create 21 mini tables otherwise.
Is this possible?
It sounds like you need to create an output data set from Surveyfreq and use another report procedure to control appearances.
Adding something like:
ODS OUTPUT crosstabs=mycrosstabs;
would send the output of the crosstab tables requests to a data set you can manipulate or print, though possibly not the prettiest. I find that "pretty" tables require some manipulation of that data set.
Hi FreelanceReinhard,
Thanks for such a quick response! These codes below create a separate table for each question though. I want them all in one big table if at all possible? There are 22 questions in the survey so it would create 21 mini tables otherwise.
Is this possible?
@nnn123 wrote:
These codes below create a separate table for each question though.
A TABLES request like Q1*Q2 creates a kind of cross-tabulation for combinations of Q1 and Q2 values, so each of the "separate tables" is for a combination of two questions.
Theoretically one could imagine a similar cross-tabulation for a combination of 22 questions (like Q1*Q2*Q3*...*Q22), but in many cases this would be very large, considering that even 22 yes/no questions would have 2**22=4,194,304 possible combinations of answers.
Can you outline the layout of your desired "big table"?
@nnn123 wrote:
Hi FreelanceReinhard,
Thanks for such a quick response! These codes below create a separate table for each question though. I want them all in one big table if at all possible? There are 22 questions in the survey so it would create 21 mini tables otherwise.
Is this possible?
It sounds like you need to create an output data set from Surveyfreq and use another report procedure to control appearances.
Adding something like:
ODS OUTPUT crosstabs=mycrosstabs;
would send the output of the crosstab tables requests to a data set you can manipulate or print, though possibly not the prettiest. I find that "pretty" tables require some manipulation of that data set.
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!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.