Return to Snippet

Revision: 5852
at April 8, 2008 03:33 by webonomic


Initial Code
proc format;
  value respfmt
   0='jim'
   2='joe'
   4='jon'
   8='jan'
   6='jake'
  10='jack'
  12='jill'
  14='josh';
run;

data have;
  input response1-response3;
  cards;
0 0 0
1 0 0
0 1 0
0 0 1
1 1 0
1 0 1
0 1 1
1 1 1
;

data want (drop=i);
  set have;
  array resp(*) response1-response3;
  format responses respfmt.;
  responses=0;
  do i=1 to 3;
    if resp(i) eq 1 then
     responses+2**i;
  end;
run;

proc print data=want;
run;

Initial URL
http://jaredprins.squarespace.com/blog/2008/4/8/create-one-response-from-check-all-that-apply-variables.html

Initial Description
Below is some code written for creating one response from survey questions where the respondent checks all that apply.

Initial Title
Create one response from "check all that apply" variables

Initial Tags
data

Initial Language
SAS