<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to transpose multiple response data from long to wide and dummy code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-transpose-multiple-response-data-from-long-to-wide-and/m-p/816951#M322488</link>
    <description>Thank you for sharing your code. Somehow I was not able to get the data as shown. My actual ItemIDs are longer, more like I45609, I46874, etc. and they are not in sequential order (could this be the problem?). Somehow I got the item IDs listed as I45609AB, I45609ABC, I45609ABD, I45609ABE, etc. and the dummy code did not work correctly.</description>
    <pubDate>Tue, 07 Jun 2022 19:59:14 GMT</pubDate>
    <dc:creator>lapetitemaman</dc:creator>
    <dc:date>2022-06-07T19:59:14Z</dc:date>
    <item>
      <title>How to transpose multiple response data from long to wide and dummy code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transpose-multiple-response-data-from-long-to-wide-and/m-p/816925#M322485</link>
      <description>&lt;P&gt;Greetings everyone,&lt;BR /&gt;&lt;BR /&gt;I have an exam dataset for multiple response items but need to separate each option and transpose the dataset from long to wide then dummy code each option. Not all examinees answered all questions. Item1 and Item2 have 5 options (2 correct answers) while Item3 has 6 options (3 correct answers). How do I achieve this? Any help is much appreciated.&lt;BR /&gt;&lt;BR /&gt;data exam;&lt;BR /&gt;input ID $ ItemID $ Response $;&lt;BR /&gt;cards;&lt;BR /&gt;1 Item1 BC&lt;BR /&gt;1 Item3 ACD&lt;BR /&gt;2 Item1 CD&lt;BR /&gt;2 Item2 AC&lt;BR /&gt;2 Item3 BCD&lt;BR /&gt;3 Item1 AB&lt;BR /&gt;3 Item2 BD&lt;BR /&gt;4 Item2 CE&lt;BR /&gt;4 Item3 ABF&lt;BR /&gt;5 Item1 AE&lt;BR /&gt;5 Item2 BD&lt;BR /&gt;5 Item3 BEF&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;data need;&lt;BR /&gt;input ID $ Item1A Item1B Item1C Item1D Item1E Item2A Item2B Item2C Item2D Item2E Item3A Item3B Item3C Item3D Item3E Item3F;&lt;BR /&gt;cards;&lt;BR /&gt;1 0 1 1 0 0 . . . . . 1 0 1 1 0 0&lt;BR /&gt;2 0 0 1 1 0 1 0 1 0 0 0 1 1 1 0 0&lt;BR /&gt;3 1 1 0 0 0 0 1 0 1 0 . . . . . .&lt;BR /&gt;4 0 0 1 0 1 . . . . . 1 1 0 0 0 1&lt;BR /&gt;5 1 0 0 0 1 0 1 0 1 0 0 1 0 0 1 1&lt;BR /&gt;;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 18:31:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transpose-multiple-response-data-from-long-to-wide-and/m-p/816925#M322485</guid>
      <dc:creator>lapetitemaman</dc:creator>
      <dc:date>2022-06-07T18:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to transpose multiple response data from long to wide and dummy code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transpose-multiple-response-data-from-long-to-wide-and/m-p/816941#M322486</link>
      <description>&lt;P&gt;Didn't we do this this the other day?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data exam;
   infile cards missover;
   input ID $ ItemID $ response $1. @;
   do while(not missing(Response));
      output;
      input response $1. @;
      end;
   cards;
1 Item1 BC
1 Item3 ACD
2 Item1 CD
2 Item2 AC
2 Item3 BCD
3 Item1 AB
3 Item2 BD
4 Item2 CE
4 Item3 ABF
5 Item1 AE
5 Item2 BD
5 Item3 BEF
;;;;
   run;
proc print;
   run;
data examv/view=examv;
   set exam(drop=id) exam;
   run;
proc sort data=examv out=exam2;
   by id itemid;
   run;
proc summary data=exam2 nway completetypes classdata=exam;
   by id itemid;
   class response;
   output out=exam3(drop=_type_);
   run;
proc transpose data=exam3 out=want(drop=_name_ where=(not missing(id)));
   by id;
   var _freq_;
   id itemid response;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 895px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72052iF00EBB98FCDF1437/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;data EXAM:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 169px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72053iBA594BBE5DADA9F9/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 19:21:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transpose-multiple-response-data-from-long-to-wide-and/m-p/816941#M322486</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2022-06-07T19:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to transpose multiple response data from long to wide and dummy code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transpose-multiple-response-data-from-long-to-wide-and/m-p/816951#M322488</link>
      <description>Thank you for sharing your code. Somehow I was not able to get the data as shown. My actual ItemIDs are longer, more like I45609, I46874, etc. and they are not in sequential order (could this be the problem?). Somehow I got the item IDs listed as I45609AB, I45609ABC, I45609ABD, I45609ABE, etc. and the dummy code did not work correctly.</description>
      <pubDate>Tue, 07 Jun 2022 19:59:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transpose-multiple-response-data-from-long-to-wide-and/m-p/816951#M322488</guid>
      <dc:creator>lapetitemaman</dc:creator>
      <dc:date>2022-06-07T19:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to transpose multiple response data from long to wide and dummy code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-transpose-multiple-response-data-from-long-to-wide-and/m-p/816963#M322493</link>
      <description>&lt;P&gt;Pay attention to the my EXAM data.&amp;nbsp; It has one observation for each value of RESPONSE.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 20:30:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-transpose-multiple-response-data-from-long-to-wide-and/m-p/816963#M322493</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2022-06-07T20:30:47Z</dc:date>
    </item>
  </channel>
</rss>

