SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
FelipOH
Calcite | Level 5

Hi:

 

I am having trouble analyzing Multiple Choice questions of a survey.

Survey Monkey provided me a table with all answers to my questions.

 

For multiple choice questions it coded each choice into one variable.

When I analyze the data for one question, I get many tables (one for each variable).

I would like to know if it possible to get all "choice" variables in one single table:

 

With the current code:

 

Proc freq data=work.cmoj;
Tables (
Principales_act_1
Principales_act_2
Principales_act_3
Principales_act_4
Principales_act_5
Principales_act_6
Principales_act_7
Principales_act_otro) *Attendance_2019/ nocol norow;
Run;

 

I get one table for each variable, but what I want to do is have one table that includes all choice variable in rows, and the crossed variable choices in columns.

 

Thank you very much.

 

 

 

4 REPLIES 4
Reeza
Super User
You need to change your data structure. Transpose your data such that you have your data structured such as:


ID Question Response Attendance_2019
1 1 1 0
1 2 5 0
1 3 4 0
1 4 3 0

Then you can use a proc freq. Or you can capture those results and then use PROC TRANSPOSE on the results. Either are options.

FelipOH
Calcite | Level 5

Hi Reeza:

Thank you very much for answer. I think transposing would't do what I need.

 

My data structure is in this way:

 

Attribute__1Attribute__2Attribute__3Attribute__4Attribute__5Type_assit
    Socializefreq
SessionsCongress   ocas
SessionsCongressCertificationSocial ServiceSocializefreq
Sessions    ocas
SessionsCongressCertification  freq
SessionsCongressCertification  ocas
SessionsCongressCertification Socializefreq

 

What I want to read is in this way:

 

 freqocasTotalfreqocasTotal
Sessions1091936%38%37%
Congress761325%25%25%
Certification63921%13%17%
Social Service2247%8%8%
Socialize34711%17%13%
 282452100%100%100%

 

Hope this can illustrate my issue, thanks again for your time.

 

Reeza
Super User
Transposing would do exactly what you want. Have you tried it?

proc transpose data=have out=long;
by type_assist;
var attribute1-attribute5;
run;

proc freq data=long;
table col1*type_assist;
run;

Or PROC TABULATE for percentages.
This is one approach, there are others. Feel free to choose the solution that meets your needs.
FelipOH
Calcite | Level 5
Thank you very much for the info!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1525 views
  • 0 likes
  • 2 in conversation