<?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 once for all vars?! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Transpose-once-for-all-vars/m-p/907159#M358129</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Thanks for the information!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 09 Dec 2023 13:20:43 GMT</pubDate>
    <dc:creator>kimmorgan</dc:creator>
    <dc:date>2023-12-09T13:20:43Z</dc:date>
    <item>
      <title>How to Transpose once for all vars?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Transpose-once-for-all-vars/m-p/907139#M358120</link>
      <description>&lt;P&gt;Get data structure below. How to transpose once for all variables?!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc transpose data=have out=need;&lt;/P&gt;
&lt;P&gt;by seq_id;&lt;/P&gt;
&lt;P&gt;id time;&lt;/P&gt;
&lt;P&gt;var var1 var2 var3;&lt;/P&gt;
&lt;P&gt;run;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the outcome is stacked for all variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OR anyway to do this by SQL or data step?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;time	seq_id	var1	var2	var3 	…
1120	1	…			
1120	2	…			
1120	3	…			
1120	4	…			
1125	1	…			
1125	2	…			
1125	3	..			
1125	4	…			
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 09 Dec 2023 01:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Transpose-once-for-all-vars/m-p/907139#M358120</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2023-12-09T01:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to Transpose once for all vars?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Transpose-once-for-all-vars/m-p/907145#M358122</link>
      <description>&lt;P&gt;Below article explains and provides macros for transposing that exceed what a single Proc Transpose can do.&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Transpose-your-analysis-data-with-the-MAKELONG-and-MAKEWIDE/ta-p/791732" target="_self"&gt;Transpose your analysis data with the %MAKELONG and %MAKEWIDE macro&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The macros are available from within the article.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1702088950440.png" style="width: 656px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/91099i6D2A05D41CD6EFA2/image-dimensions/656x71?v=v2" width="656" height="71" role="button" title="Patrick_0-1702088950440.png" alt="Patrick_0-1702088950440.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Dec 2023 02:29:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Transpose-once-for-all-vars/m-p/907145#M358122</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-12-09T02:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to Transpose once for all vars?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Transpose-once-for-all-vars/m-p/907146#M358123</link>
      <description>&lt;P&gt;I don't understand.&amp;nbsp; Why would you create a variable using TIME as the basis for the name of the variable?&lt;BR /&gt;What use is that going to be to you?&amp;nbsp; How will you be able to calculate time differences if you have stored the time value into the NAME of a variable instead of leaving it in a the VALUE of variable where it can be referenced?&lt;/P&gt;</description>
      <pubDate>Sat, 09 Dec 2023 02:48:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Transpose-once-for-all-vars/m-p/907146#M358123</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-12-09T02:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to Transpose once for all vars?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Transpose-once-for-all-vars/m-p/907149#M358125</link>
      <description>&lt;P&gt;Since the result would be unusable for further analysis, I take it this is for reporting purposes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=have;
column seq_id (var1 var2 var3),time;
define seq_id / group;
define var1 / analysis;
define var2 / analysis;
define var3 / analysis;
define time / "" across;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 09 Dec 2023 21:35:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Transpose-once-for-all-vars/m-p/907149#M358125</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-12-09T21:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to Transpose once for all vars?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Transpose-once-for-all-vars/m-p/907154#M358128</link>
      <description>&lt;P&gt;Check my paper - MERGE Skill to transpose data.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings15/2785-2015.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings15/2785-2015.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
Try the MERGE skill proposed by me.
And that would be better if you post the result you are looking for.
*/

data have;
infile cards truncover expandtabs;
input time	seq_id	var1	var2	var3;
cards;
1120	1	1  2  3
1120	2	1  2  3
1120	3	1  2  3
1120	4	1  2  3
1125	1	1  2  3
1125	2	1  2  3
1125	3	1  2  3
1125	4	1  2  3
;

proc sql noprint;
select distinct catt('have(where=(time=',time,') rename=(var1=var1_',time,' var2=var2_',time,' var3=var3_',time,'))')
       into :merge separated by ' '
 from have;
quit;
data want;
 merge &amp;amp;merge.;
 by seq_id;
 drop time;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1702117611036.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/91100i85CD334DFE47749E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1702117611036.png" alt="Ksharp_0-1702117611036.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Dec 2023 10:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Transpose-once-for-all-vars/m-p/907154#M358128</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-12-09T10:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to Transpose once for all vars?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Transpose-once-for-all-vars/m-p/907159#M358129</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thanks for the information!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Dec 2023 13:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Transpose-once-for-all-vars/m-p/907159#M358129</guid>
      <dc:creator>kimmorgan</dc:creator>
      <dc:date>2023-12-09T13:20:43Z</dc:date>
    </item>
  </channel>
</rss>

