<?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 Transposing multiple variables with same ID in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Transposing-multiple-variables-with-same-ID/m-p/328893#M62522</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I am working on a data set that includes patientID#s, but each patient has multiple responses for one variable. (Multiple cormorbidites and complications, for example). I want to transpose them out so that I don't have extra spaces or repeated PatientIDS. How do I transpose all of these multiple row variables in one step?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I have done this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN&gt;&lt;STRONG&gt;sort&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt;=exlap.traumabase3; &lt;SPAN&gt;by&lt;/SPAN&gt; PatientNumber; &lt;SPAN&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN&gt;&lt;STRONG&gt;transpose&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt; = exlap.traumabase3 &lt;SPAN&gt;out&lt;/SPAN&gt;=exlap.traumabase1 (drop=_name_) &lt;SPAN&gt;prefix&lt;/SPAN&gt;=Comorbidites;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;by&lt;/SPAN&gt; PatientNumber;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; Comorbidities ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;*And this transposes too many comorbidities and only transposes one variable at a time. I have about 40 extra with no data listed for some reason (Comorbidities 6-Comorbidites41 have nothing listed). &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jan 2017 21:48:44 GMT</pubDate>
    <dc:creator>stancemcgraw</dc:creator>
    <dc:date>2017-01-31T21:48:44Z</dc:date>
    <item>
      <title>Transposing multiple variables with same ID</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Transposing-multiple-variables-with-same-ID/m-p/328893#M62522</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I am working on a data set that includes patientID#s, but each patient has multiple responses for one variable. (Multiple cormorbidites and complications, for example). I want to transpose them out so that I don't have extra spaces or repeated PatientIDS. How do I transpose all of these multiple row variables in one step?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I have done this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN&gt;&lt;STRONG&gt;sort&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt;=exlap.traumabase3; &lt;SPAN&gt;by&lt;/SPAN&gt; PatientNumber; &lt;SPAN&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN&gt;&lt;STRONG&gt;transpose&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt; = exlap.traumabase3 &lt;SPAN&gt;out&lt;/SPAN&gt;=exlap.traumabase1 (drop=_name_) &lt;SPAN&gt;prefix&lt;/SPAN&gt;=Comorbidites;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;by&lt;/SPAN&gt; PatientNumber;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; Comorbidities ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;*And this transposes too many comorbidities and only transposes one variable at a time. I have about 40 extra with no data listed for some reason (Comorbidities 6-Comorbidites41 have nothing listed). &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 21:48:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Transposing-multiple-variables-with-same-ID/m-p/328893#M62522</guid>
      <dc:creator>stancemcgraw</dc:creator>
      <dc:date>2017-01-31T21:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing multiple variables with same ID</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Transposing-multiple-variables-with-same-ID/m-p/328914#M62524</link>
      <description>&lt;P&gt;I would suggest looking at the macro here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.sascommunity.org/wiki/A_Better_Way_to_Flip_(Transpose)_a_SAS_Dataset" target="_blank"&gt;http://www.sascommunity.org/wiki/A_Better_Way_to_Flip_(Transpose)_a_SAS_Dataset&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise your options are to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1: Multiple proc transpose and merge the results&lt;/P&gt;
&lt;P&gt;2: Use a data step array to transpose but you need to know the maximum amount of variables before hand. The macro or option 1 doesn't require the amount before.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 22:37:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Transposing-multiple-variables-with-same-ID/m-p/328914#M62524</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-01-31T22:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing multiple variables with same ID</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Transposing-multiple-variables-with-same-ID/m-p/328922#M62526</link>
      <description>&lt;P&gt;Ok. I am not familiar with Macros at all so I am going to use multiple transpose steps, however, when I have trasnposed one variable it lists too many:&lt;/P&gt;&lt;P&gt;Cormobidites6-Cormibidites41 and there is no data there... How do I specifiy only Cormorbidites1-Cormobidites5?&lt;/P&gt;&lt;P&gt;Please see attached screenshot with empty columns of comorbidities below...&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13386i8F04AD4BF7D5EB69/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Screen Shot 2017-01-31 at 3.59.01 PM.png" title="Screen Shot 2017-01-31 at 3.59.01 PM.png" /&gt;</description>
      <pubDate>Tue, 31 Jan 2017 22:59:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Transposing-multiple-variables-with-same-ID/m-p/328922#M62526</guid>
      <dc:creator>stancemcgraw</dc:creator>
      <dc:date>2017-01-31T22:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing multiple variables with same ID</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Transposing-multiple-variables-with-same-ID/m-p/328923#M62527</link>
      <description>&lt;P&gt;That means you do have some records that have 41 comorbidities. What do you want to do with those?&lt;/P&gt;
&lt;P&gt;You can just drop the variables you don't need after if you want to keep only 5.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Typically, I've seen 25 or 10 used in these cases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you post the code you're using we can help with the modifications.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't have to write the macro, just use it. If you give the paper a quick read through it's probably the easiest method.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 23:02:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Transposing-multiple-variables-with-same-ID/m-p/328923#M62527</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-01-31T23:02:13Z</dc:date>
    </item>
  </channel>
</rss>

