<?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: Need help changing data structure in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144721#M28889</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not just find MAX of all the indicator variables for each patient_id&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc means noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by patient_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; output out=unique max=;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Jan 2015 19:33:56 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2015-01-29T19:33:56Z</dc:date>
    <item>
      <title>Need help changing data structure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144720#M28888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here are two data sets:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data1:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="8912" alt="" class="jiveImage" src="https://communities.sas.com/legacyfs/online/8912_pastedImage_0.png" style="width: 110px; height: 107px;" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;data2:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="8914" alt="" class="jiveImage" src="https://communities.sas.com/legacyfs/online/8914_pastedImage_2.png" style="width: 149px; height: 435px;" /&gt;&lt;/P&gt;&lt;P&gt;As you can see, data2 has a new observation for each time a drug was given to each patient (including duplicates). i.e. Patient 1 received 2 unique drugs (a3, s1).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I need as an end result is a merged data set by patient_id with indicator variables of whether or not the patient received any of the available drugs.&amp;nbsp; It should look like this:&lt;/P&gt;&lt;P&gt;data3:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jiveImage" src="https://communities.sas.com/legacyfs/online/8922_pastedImage_0.png" style="width: 286px; height: 110px;" /&gt;&lt;/P&gt;&lt;P&gt;What I first did in attempt to solve the problem was to add these indicator variables onto data2 which looks like this:&lt;/P&gt;&lt;P&gt;data4:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="8917" alt="" class="jiveImage" src="https://communities.sas.com/legacyfs/online/8917_pastedImage_5.png" style="width: 324px; height: 434px;" /&gt;&lt;/P&gt;&lt;P&gt;Now I need to consolidate all indicators into one line per patient, but can't figure out how to do so.&amp;nbsp; Does anyone know what my next step could be?&amp;nbsp; Or another approach starting with the initial two data sets?&amp;nbsp; Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 19:21:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144720#M28888</guid>
      <dc:creator>queso</dc:creator>
      <dc:date>2015-01-29T19:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: Need help changing data structure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144721#M28889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not just find MAX of all the indicator variables for each patient_id&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc means noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by patient_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; output out=unique max=;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 19:33:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144721#M28889</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-01-29T19:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Need help changing data structure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144722#M28890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, this gives you the look, but if you want those new chars to be numeric, then you need to convert them:&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; id drug :&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;$8.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;1 a3&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;1 a3&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;1 s1&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;2 a2&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;2 s2&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;2 s2&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;2 s3&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;2 s1&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;transpose&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;=have &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;out&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;=h1 (&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;drop&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;=_name_) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;let&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; id;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;var&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; drug;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;id&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; drug;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; h1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; char &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;_character_&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;over&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; char;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; char=ifc(missing(char),&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'0'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'1'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 19:46:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144722#M28890</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-01-29T19:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need help changing data structure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144723#M28891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would stay away from do over;. it is a very old technique and is not recommended. I was surprised it still worked.&lt;/P&gt;&lt;P&gt;Also, you should not use array names that are the same as function names such as char.&lt;/P&gt;&lt;P&gt;I suggest adding a proc sort step to eliminate duplicate ids with the same drug, as proc transpose issues warnings when I ran your code .The warnings were about the same&amp;nbsp; id values occurring in the same group.&lt;/P&gt;&lt;P&gt;Your final code would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; data have;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input id drug :$8.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cards;&lt;BR /&gt;1 a3&lt;BR /&gt;1 a3&lt;BR /&gt;1 s1&lt;BR /&gt;2 a2&lt;BR /&gt;2 s2&lt;BR /&gt;2 s2&lt;BR /&gt;2 s3&lt;BR /&gt;2 s1&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=haveout=uniquehave nodups;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by id drug;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc transpose data=uniquehave out=h1(drop=_name_);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var drug;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; id drug;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set h1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array mychar _character_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to dim(mychar);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mychar{i}=ifc(missing(mychar{i}),'0','1');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 22:02:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144723#M28891</guid>
      <dc:creator>kaade</dc:creator>
      <dc:date>2015-01-29T22:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: Need help changing data structure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144724#M28892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you implicating I am a senior citizen? &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;&lt;P&gt;Kidding aside, if the only reason for not using 'do over' is being OLD, it sounds a little shaky, doesn't? Besides, similar 'do over' has be resurrected in the 9.4 Hash objects?&lt;/P&gt;&lt;P&gt;About Char array, I admit I dropped the ball there, it was not a good practice to use char, a SAS reserved function name as an array name.&lt;/P&gt;&lt;P&gt;I am aware of the warning in Transpose, and the 'let' option is invented for that purpose, so we can skip one dedup step, depending on the size of the data, sometimes it worths the warning for the gaining on efficiency.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my2cents,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 22:18:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144724#M28892</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-01-29T22:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: Need help changing data structure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144725#M28893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since you've already created Data4, just do what John &lt;A __default_attr="468858" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; says.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another option would be to do something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data data2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set data2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; flg=1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* something to collapse the data */&lt;/P&gt;&lt;P&gt;proc summary nway missing data=data2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; class _all_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output out=data2a(drop=_:);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=data2a&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out=data3(drop=_name_);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by patient_id;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var flg;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; id drug;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will give you missing and 1, then you'll have to set the missing to 0 if you really need them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 22:23:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144725#M28893</guid>
      <dc:creator>BurntDirt</dc:creator>
      <dc:date>2015-01-29T22:23:16Z</dc:date>
    </item>
    <item>
      <title>Re: Need help changing data structure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144726#M28894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all for the help.&amp;nbsp; Problem has been solved and moving forward.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 22:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144726#M28894</guid>
      <dc:creator>queso</dc:creator>
      <dc:date>2015-01-29T22:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: Need help changing data structure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144727#M28895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;As a senior citizen, I resemble that remark! I agree that do over isn't in the documentation other than the fact that they state that it isn't supported in SCL.&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;However, more interestingly, it is used in a number of the 9.4 examples. e.g.:&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;A class="active_link" href="http://support.sas.com/documentation/onlinedoc/stat/ex_code/121/modstyex.html&amp;lt;br/&amp;gt;http://support.sas.com/documentation/onlinedoc/stat/ex_code/121/clusex6.html&amp;lt;br/&amp;gt;" title="http://support.sas.com/documentation/onlinedoc/stat/ex_code/121/modstyex.html&amp;lt;br/&amp;gt;http://support.sas.com/documentation/onlinedoc/stat/ex_code/121/clusex6.html&amp;lt;br/&amp;gt;"&gt;http://support.sas.com/documentation/onlinedoc/stat/ex_code/121/modstyex.html&lt;BR /&gt;http://support.sas.com/documentation/onlinedoc/stat/ex_code/121/clusex6.html&lt;BR /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/onlinedoc/stat/ex_code/121/modstyex.html&amp;lt;br/&amp;gt;http://support.sas.com/documentation/onlinedoc/stat/ex_code/121/clusex6.html&amp;lt;br/&amp;gt;" title="http://support.sas.com/documentation/onlinedoc/stat/ex_code/121/modstyex.html&amp;lt;br/&amp;gt;http://support.sas.com/documentation/onlinedoc/stat/ex_code/121/clusex6.html&amp;lt;br/&amp;gt;"&gt;&lt;BR /&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 22:41:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144727#M28895</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2015-01-29T22:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: Need help changing data structure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144728#M28896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; For future folks reading this post, an alternate solution would have been to use PROC REPORT or PROC TABULATE on the DRUG2 dataset directly, without needing a PROC SUMMARY or a PROC TRANSPOSE.&lt;/P&gt;&lt;P&gt;Cynthia&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;data data2;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; infile datalines;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; input ptid drug $;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;return;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;1 a3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;1 a3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;1 s1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;2 a2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;2 s2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;2 s2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;2 s3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;2 s1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;3 s2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;3 b1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;3 s2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;3 s2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;3 s3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;3 s3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;3 s1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;options missing=0;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;ods listing close;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;ods html file='c:\temp\drug_report.html';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;proc report data=data2 split='*';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; title 'Use PROC REPORT';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; column ptid drug n;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; define ptid / group style(column)=Header;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; define drug / across;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; define n / 'Patient*Total';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; rbreak after / summarize style=Header;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;proc tabulate data=data2 f=6.;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; title 'Use PROC TABULATE';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; class ptid drug;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; table ptid all*{s=Header},&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; drug*n all;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; keylabel all='Total'&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n=' ';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;ods html close;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/11029iFCBB47CE9577414C/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="compare_report_tabulate.png" title="compare_report_tabulate.png" /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Jan 2015 14:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144728#M28896</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2015-01-31T14:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need help changing data structure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144729#M28897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Queso: Since you still haven't marked this question as "answered", here is an alternative solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course, since you have already created your data4 file, data_null_'s proposal is all that you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, if not, the following wouldn't require much more than what you did to create your data4 file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data data1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input patient_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data data2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input patient_id drug $;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;1 a3&lt;/P&gt;&lt;P&gt;1 a3&lt;/P&gt;&lt;P&gt;1 s1&lt;/P&gt;&lt;P&gt;2 a2&lt;/P&gt;&lt;P&gt;2 s2&lt;/P&gt;&lt;P&gt;2 s2&lt;/P&gt;&lt;P&gt;2 s3&lt;/P&gt;&lt;P&gt;2 s1&lt;/P&gt;&lt;P&gt;3 s2&lt;/P&gt;&lt;P&gt;3 b1&lt;/P&gt;&lt;P&gt;3 s2&lt;/P&gt;&lt;P&gt;3 s2&lt;/P&gt;&lt;P&gt;3 s3&lt;/P&gt;&lt;P&gt;3 s3&lt;/P&gt;&lt;P&gt;3 s1&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=data2 out=data3 (drop=_name_) let prefix=_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by patient_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var drug;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id drug;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (drop=_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge data1 data3;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array _drugs(*) _:;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array drugs(*) a1 a2 a3 b1 s1 s2 s3;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by patient_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _i=1 to dim(drugs);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; drugs(_i)=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _i=1 to dim(_drugs);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _drugs(_i)='a1' then drugs(1)=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if _drugs(_i)='a2' then drugs(2)=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if _drugs(_i)='a3' then drugs(3)=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if _drugs(_i)='b1' then drugs(4)=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if _drugs(_i)='s1' then drugs(5)=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if _drugs(_i)='s2' then drugs(6)=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if _drugs(_i)='s3' then drugs(7)=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Jan 2015 19:18:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144729#M28897</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2015-01-31T19:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: Need help changing data structure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144730#M28898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Cynthia,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I liked your example, but he didn't want to total them up.&lt;/P&gt;&lt;P&gt;He just wanted indicator variables for them (1=exist; 0=not exist) and he was asking for a dataset.&lt;/P&gt;&lt;P&gt;Could be a design matrix or some other reason for needing these in a dataset.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Feb 2015 20:21:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-changing-data-structure/m-p/144730#M28898</guid>
      <dc:creator>BurntDirt</dc:creator>
      <dc:date>2015-02-02T20:21:54Z</dc:date>
    </item>
  </channel>
</rss>

