<?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 Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/642916#M191850</link>
    <description>&lt;P&gt;I'm trying to write a macro that can take any data set and any key variables and convert from wide form to long form. I'm having a hard time visualizing how this is possible.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 25 Apr 2020 17:39:46 GMT</pubDate>
    <dc:creator>matoma</dc:creator>
    <dc:date>2020-04-25T17:39:46Z</dc:date>
    <item>
      <title>Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/642916#M191850</link>
      <description>&lt;P&gt;I'm trying to write a macro that can take any data set and any key variables and convert from wide form to long form. I'm having a hard time visualizing how this is possible.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Apr 2020 17:39:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/642916#M191850</guid>
      <dc:creator>matoma</dc:creator>
      <dc:date>2020-04-25T17:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/642918#M191851</link>
      <description>&lt;P&gt;I eventually want to apply it to this data set&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Annotation 2020-04-25 134027.png" style="width: 547px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/38704i6DC1A60C695C8AF0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Annotation 2020-04-25 134027.png" alt="Annotation 2020-04-25 134027.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Apr 2020 17:41:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/642918#M191851</guid>
      <dc:creator>matoma</dc:creator>
      <dc:date>2020-04-25T17:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/642919#M191852</link>
      <description>&lt;P&gt;Before writing the macro think about what SAS code you want to run.&amp;nbsp; Then you can start thinking about how to generate that code using macro logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you asking for something different than PROC TRANSPOSE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=want ;
  by key1 key2 ;
  var _all_ ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 Apr 2020 17:57:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/642919#M191852</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-25T17:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/642920#M191853</link>
      <description>&lt;P&gt;Don't write your own macro. Use the %UNTRANSPOSE macro&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2018/2419-2018.pdf" target="_blank"&gt;https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2018/2419-2018.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Apr 2020 17:58:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/642920#M191853</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-25T17:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/642925#M191854</link>
      <description>&lt;P&gt;That would be a PROC TRANSPOSE.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=want;
by ID GENDER;
VAR age: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I suppose you could make it a macro but I don't see a huge amount of value in that beyond using the procedure. Here are some tutorials on transposing if you want to understand the different option in SAS further. There are also many user macros already written, this is one written by some of the users here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/A-better-way-to-FLIP-i-e-transpose-make-wide-a-dataset/ta-p/433620" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/A-better-way-to-FLIP-i-e-transpose-make-wide-a-dataset/ta-p/433620&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&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, 25 Apr 2020 18:23:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/642925#M191854</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-04-25T18:23:00Z</dc:date>
    </item>
  </channel>
</rss>

