We Recommend

Version Control with Subversion Version Control with Subversion
Written by members of the Subversion open source development team, Version Control with Subversion introduces the powerful new versioning tool designed to be the successor to the Concurrent Version System or CVS. CVS users will find the "look and feel" Subversion comfortably familiar, but under the surface it's far more flexible, robust, and usable, and more importantly, it improves on CVS's more notable flaws.


Ballyhoo


Posted By

webonomic on 04/08/08


Tagged

data dataset shaping


Versions (?)


Create one response from "check all that apply" variables


Published in: SAS 


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

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


  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;

Report this snippet 

You need to login to post a comment.