<?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: From One Variable to Multiple Variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/From-One-Variable-to-Multiple-Variables/m-p/697370#M213094</link>
    <description>&lt;P&gt;Pre process your Measure field to transform the measure names into your expected variable names&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if measure = 'Height (In)' then varname = "HtIn";&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can simply sort and transpose your dataset&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort ...; by SSN VisitDT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc transpose ... ;&lt;/P&gt;
&lt;P&gt;by SSN VisitDt;&lt;/P&gt;
&lt;P&gt;ID varname;&lt;/P&gt;
&lt;P&gt;var value;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 07 Nov 2020 22:06:11 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2020-11-07T22:06:11Z</dc:date>
    <item>
      <title>From One Variable to Multiple Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/From-One-Variable-to-Multiple-Variables/m-p/697369#M213093</link>
      <description>&lt;P&gt;Hello! I hope my title makes sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So here is the output data set I have for one of my data sets:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;STRONG&gt;Var1&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;STRONG&gt;Var2&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;STRONG&gt;Var3&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;Var4&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01JAN2010&lt;/TD&gt;&lt;TD&gt;Height&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;111-11-1111&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01JAN2010&lt;/TD&gt;&lt;TD&gt;Weight&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;111-11-1111&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01JAN2010&lt;/TD&gt;&lt;TD&gt;Systolic BP&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;111-11-1111&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01JAN2010&lt;/TD&gt;&lt;TD&gt;Diastolic BP&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;111-11-1111&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN&gt;06JAN2011&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;Height&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;111-11-1111&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN&gt;06JAN2011&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;Weight&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;111-11-1111&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN&gt;06JAN2011&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;Systolic BP&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;111-11-1111&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN&gt;06JAN2011&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;Diastolic BP&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;111-11-1111&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I need it to look like (this is a separate output data set I've already completed):&lt;/P&gt;&lt;P&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;&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;STRONG&gt;Var1&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;STRONG&gt;Var2&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Var3&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;Var4&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;STRONG&gt;Var5&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Var6&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;111-11-1111&lt;/TD&gt;&lt;TD&gt;30AUG2010&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;111-11-1111&lt;/TD&gt;&lt;TD&gt;22AUG2011&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;111-11-1111&lt;/TD&gt;&lt;TD&gt;31AUG2012&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;111-11-1111&lt;/TD&gt;&lt;TD&gt;05SEP2013&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;111-11-1111&lt;/TD&gt;&lt;TD&gt;12SEP2014&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;I need each subject to have 4 observations organized by visit date, height, weight, SBP, and DBP. Currently, in the first data set, each subject has 16 observations. The variables currently include height, weight, SBP, DBP, and the values for each, and I need each of those to be their own variable and value. And then I need only 1 observation for each date for each SSN instead of 4 observations for each date and SSN.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm honestly not sure where to even begin. If I can get some guidance (even if it's just what functions to look into myself) I would greatly appreciate it!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Dec 2020 15:21:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/From-One-Variable-to-Multiple-Variables/m-p/697369#M213093</guid>
      <dc:creator>jporterf</dc:creator>
      <dc:date>2020-12-10T15:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: From One Variable to Multiple Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/From-One-Variable-to-Multiple-Variables/m-p/697370#M213094</link>
      <description>&lt;P&gt;Pre process your Measure field to transform the measure names into your expected variable names&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if measure = 'Height (In)' then varname = "HtIn";&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can simply sort and transpose your dataset&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort ...; by SSN VisitDT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc transpose ... ;&lt;/P&gt;
&lt;P&gt;by SSN VisitDt;&lt;/P&gt;
&lt;P&gt;ID varname;&lt;/P&gt;
&lt;P&gt;var value;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Nov 2020 22:06:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/From-One-Variable-to-Multiple-Variables/m-p/697370#M213094</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-11-07T22:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: From One Variable to Multiple Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/From-One-Variable-to-Multiple-Variables/m-p/697371#M213095</link>
      <description>&lt;P&gt;Please clarify something. Is the desired output a table that you can e-mail or put in a report? Or is the desired output a SAS data set?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Either way, do not try doing this in a SAS data step. Either PROC REPORT or PROC TRANSPOSE will be the easiest solution.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Nov 2020 22:10:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/From-One-Variable-to-Multiple-Variables/m-p/697371#M213095</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-11-07T22:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: From One Variable to Multiple Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/From-One-Variable-to-Multiple-Variables/m-p/697373#M213096</link>
      <description>&lt;P&gt;Transposing data tutorials:&lt;BR /&gt;Long to Wide:&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Wide to Long:&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-wide-to-long-using-proc-transpose/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-wide-to-long-using-proc-transpose/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/reshaping-data-wide-to-long-using-a-data-step/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/reshaping-data-wide-to-long-using-a-data-step/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;And sometimes a double transpose is needed for extra wide data sets:&lt;BR /&gt;&lt;A href="https://gist.github.com/statgeek/2321b6f62ab78d5bf2b0a5a8626bd7cd" target="_blank"&gt;https://gist.github.com/statgeek/2321b6f62ab78d5bf2b0a5a8626bd7cd&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Nov 2020 22:57:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/From-One-Variable-to-Multiple-Variables/m-p/697373#M213096</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-11-07T22:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: From One Variable to Multiple Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/From-One-Variable-to-Multiple-Variables/m-p/697471#M213146</link>
      <description>&lt;P&gt;The desired output is SAS data set. I need to combine this data set with two other ones to create a final data set.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Nov 2020 22:50:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/From-One-Variable-to-Multiple-Variables/m-p/697471#M213146</guid>
      <dc:creator>jporterf</dc:creator>
      <dc:date>2020-11-08T22:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: From One Variable to Multiple Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/From-One-Variable-to-Multiple-Variables/m-p/697472#M213147</link>
      <description>&lt;P&gt;I thought this might deal with re-structuring data, thank you!&lt;/P&gt;</description>
      <pubDate>Sun, 08 Nov 2020 22:50:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/From-One-Variable-to-Multiple-Variables/m-p/697472#M213147</guid>
      <dc:creator>jporterf</dc:creator>
      <dc:date>2020-11-08T22:50:53Z</dc:date>
    </item>
  </channel>
</rss>

