Create one response from "check all that apply" variables


/ Published in: SAS
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. proc format;
  2. value respfmt
  3. 0='jim'
  4. 2='joe'
  5. 4='jon'
  6. 8='jan'
  7. 6='jake'
  8. 10='jack'
  9. 12='jill'
  10. 14='josh';
  11. run;
  12.  
  13. data have;
  14. input response1-response3;
  15. cards;
  16. 0 0 0
  17. 1 0 0
  18. 0 1 0
  19. 0 0 1
  20. 1 1 0
  21. 1 0 1
  22. 0 1 1
  23. 1 1 1
  24. ;
  25.  
  26. data want (drop=i);
  27. set have;
  28. array resp(*) response1-response3;
  29. format responses respfmt.;
  30. responses=0;
  31. do i=1 to 3;
  32. if resp(i) eq 1 then
  33. responses+2**i;
  34. end;
  35. run;
  36.  
  37. proc print data=want;
  38. run;

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

Report this snippet


Comments


You need to login to view comments.