Download presentation
Presentation is loading. Please wait.
Published byHugh Stanley Modified over 9 years ago
1
A Concise Display of Multiple Response Items Patrick Thornton
2
Multiple Response Items: Outline Example item, response & indicator variables Summarize responses using indicator variables and a PROC FREQ Summarizing responses into a single table –Create binary variable from indicators variables –Create a decimal variable from the binary –Create a MULTILABEL format for the decimal –Summarize responses in PROC TABULATE Conclusion
3
Multiple Response Item with Example Responses Are you proficient at speaking the following languages (answer all that apply)? –Spanish (yes) –English (yes) –Chinese (no)
4
Language Indicator Variables to Store the Responses data mydata; length e1-e3 gender 8.; label e1 = 'Spanish' e2='English' e3='Chinese' gender='Gender'; input e1 e2 e3 gender; cards; 1 1 0 1 ;run;
5
Formatting Language Indicator Variables proc format; value yesno 1 = 'Yes' 0 = 'No'; value gender 1 ='Male' 2 = 'Female'; run; data mydata; set mydata; format e1-e3 yesno. gender gender.; run;
6
Using PROC FREQ and the Indicator Variables to Display Language Responses TITLE1 “Standard Reporting Generates a Table for Each Variable”; PROC FREQ data=mydata; TABLE e1-e3; run;
7
Using PROC FREQ and the Indicator Variables to Display Language Responses
9
Using PROC TABULATE to Display the Language Responses
10
Creating Binary Variable from the Indicator Variables data mydata; set mydata; length language_binary $3.; language_binary = strip(catt(of e3 e2 e1)); run;
11
List Indicator and Binary Variables
12
Create a MULTILABEL Format based on 3 Character Binary Variable Proc format; value $langf (multilabel notsorted ) '000' = 'Missing' '001','011','101','111' = 'Spanish' '010','011','110','111'= 'English' '100','101','110','111'='Chinese'; run;
13
List Indicator and Binary Variables
14
Create a MULTILABEL Format based on 2 Character Binary Variable Proc format; value $langf (multilabel notsorted) '00' = 'Missing' '01','11' = 'Spanish' '10','11', = 'English'; Run;
15
Creating Binary and Decimal Variables from the Indicator Variables data mydata; set mydata; length language_binary $3. language_profile 8.; language_binary = strip(catt(of e3 e2 e1)); language_profile=input(language_binary,binary3.); run;
16
Listing of Binary and Decimal Variables
17
MULTILABEL Format to Label Decimal Values Proc format; value langf (multilabel notsorted ) 0 = 'Missing' 1,3,5,7 = 'Spanish' 2,3,6,7= 'English' 4,5,6,7= 'Chinese'; Run;
18
PROC TABULATE, MULTILABEL, and Decimal Variable proc tabulate data=mydata ; class language_profile /ORDER=DATA PRELOADFMT MLF; table language_profile="Language" all='Total', (n* format=10.0 pctn='%'*format=7.1)/ box='Table 1 Student reported language proficiency' rtspace=20; format language_profile $langf. ; run;
19
Single Table Display of Multiple Response Language Item
20
PROC TABULATE, MULTILABEL, Decimal Variable, and Column Variable proc tabulate data=mydata ; class language_profile /ORDER=DATA PRELOADFMT MLF; class gender; table language_profile="Language" all='Total', gender* (n* format=10.0 pctn='%'*format=7.1)/ box='Table 2 Student reported language proficiency by gender' rtspace=20; format language_profile $langf. ; run;
21
Single Table Display of Multiple Response Language Item and Gender
22
Macro Program for Creating the Multi-Label Format Thornton, P. (2013). A Concise Display of Multiple Response Items. Proceedings of the 2013 SAS Global Forum, San Francisco, CA
23
Bonus: BAND Function – Is it useful? BAND is a function that performs a bitwise AND operation on two arguments –The result is a multiplication of each position in the binary form of two numbers –x=BAND (arg1,arg2) Arg1 = 001 Arg2 = 001 X = 1 –By passing 001 as Arg2, I can confirm a 1 is in the same position in Arg1
24
Is it useful to subset OBS with BAND? proc print data=mydata label; var language_binary language_profile e3-e1; where e1 = 1; run; proc print data=mydata label; var language_binary language_profile e3-e1; where band(language_profile,001); run;
25
Test of the BAND Function
26
Test of the BAND Function (con’t)
27
It does seem possible to subset OBS based on BAND proc print data=example label; var language_binary language_profile e6-e1; where band(language_profile,101010); run; Data subset; set example; if band(language_profile,101010); Run;
28
Conclusion Creating binary and decimal variables from a series of indicator variables is useful –Display responses with PROC TABULATE and MULTILABEL format –A macro program can be used to build the format Limitation –Observations where missing responses cannot be considered a “no” response must be removed from the display –Maximum of about 10 indicators (ie. 2**10-1 combinations)
29
SAS is a registered trademark or trademark of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand and product names are registered trademarks or Trademarks of their respective companies. The Power To Know ™ SAS ®
30
Contact Information Patrick Thornton, Ph.D. 333 Ravenswood Ave Menlo Park, CA 94025-3493 650 859-5583 Patrick.thornton@sri.com
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.