<?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: PROC TRANPOSE with &amp;quot;multiple VAR&amp;quot; statements in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-TRANPOSE-with-quot-multiple-VAR-quot-statements/m-p/820037#M323646</link>
    <description>&lt;P&gt;&amp;nbsp;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the info!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's deffinetely good solution, but the problem occurs when you have many "col_n" and variables - then I need to make many single transposes and merge by many columns. I just thought that maybe there is "one-step" solution of this problem &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jun 2022 14:57:38 GMT</pubDate>
    <dc:creator>filippo_kow</dc:creator>
    <dc:date>2022-06-23T14:57:38Z</dc:date>
    <item>
      <title>PROC TRANPOSE with "multiple VAR" statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-TRANPOSE-with-quot-multiple-VAR-quot-statements/m-p/820032#M323643</link>
      <description>&lt;P&gt;&amp;nbsp;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a little problem. I have the following dataset:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="filippo_kow_0-1655995106866.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72681iFAB581B1719B6DE6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="filippo_kow_0-1655995106866.png" alt="filippo_kow_0-1655995106866.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;and in the results I would like to obtain duplicated record for x1/x2 and y1/y2 variables, it means something like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="filippo_kow_1-1655995288699.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72682i46F9E43E8B35EC50/image-size/medium?v=v2&amp;amp;px=400" role="button" title="filippo_kow_1-1655995288699.png" alt="filippo_kow_1-1655995288699.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I will have only one variable, then I would simply use:&lt;/P&gt;&lt;P&gt;proc transpose data=test out=tr;&lt;BR /&gt;by trans1 trans2;&lt;BR /&gt;var x1 x2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the problem is with multiple variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please help me how can I obtain the result (using proc transpose or something else) ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2022 14:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-TRANPOSE-with-quot-multiple-VAR-quot-statements/m-p/820032#M323643</guid>
      <dc:creator>filippo_kow</dc:creator>
      <dc:date>2022-06-23T14:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: PROC TRANPOSE with "multiple VAR" statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-TRANPOSE-with-quot-multiple-VAR-quot-statements/m-p/820036#M323645</link>
      <description>&lt;P&gt;Do them separately and combine.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=test out=X;
by trans1 trans2;
var x1 x2;
run;
proc transpose data=test out=X(rename=(_name_=_name2_ col1=col2));
by trans1 trans2;
var x1 x2;
run;
data want;
  merge x y;
  by trans1 trans2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or just code it yourself.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set test ;
  array _x x1-x2;
  array _y y1 y2;
  do index=1 to dim(_x) ;
     x=_x[index];
     y=_y[index];
     output;
   end;
  drop x1-x2 y1-y2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jun 2022 14:52:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-TRANPOSE-with-quot-multiple-VAR-quot-statements/m-p/820036#M323645</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-23T14:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: PROC TRANPOSE with "multiple VAR" statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-TRANPOSE-with-quot-multiple-VAR-quot-statements/m-p/820037#M323646</link>
      <description>&lt;P&gt;&amp;nbsp;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the info!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's deffinetely good solution, but the problem occurs when you have many "col_n" and variables - then I need to make many single transposes and merge by many columns. I just thought that maybe there is "one-step" solution of this problem &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2022 14:57:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-TRANPOSE-with-quot-multiple-VAR-quot-statements/m-p/820037#M323646</guid>
      <dc:creator>filippo_kow</dc:creator>
      <dc:date>2022-06-23T14:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: PROC TRANPOSE with "multiple VAR" statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-TRANPOSE-with-quot-multiple-VAR-quot-statements/m-p/820039#M323647</link>
      <description>&lt;P&gt;&amp;nbsp;Hi again Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I missed your second data step - it is exactly what I meant - thanks a lot!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Cheers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;Filip&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2022 15:00:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-TRANPOSE-with-quot-multiple-VAR-quot-statements/m-p/820039#M323647</guid>
      <dc:creator>filippo_kow</dc:creator>
      <dc:date>2022-06-23T15:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: PROC TRANPOSE with "multiple VAR" statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-TRANPOSE-with-quot-multiple-VAR-quot-statements/m-p/820040#M323648</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/428270"&gt;@filippo_kow&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the info!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's deffinetely good solution, but the problem occurs when you have many "col_n" and variables - then I need to make many single transposes and merge by many columns. I just thought that maybe there is "one-step" solution of this problem &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Perhaps you can make a better example?&lt;/P&gt;
&lt;P&gt;You can also transform to TALL format.&amp;nbsp; Parse out the NAME and the NUMBER from the name and reorder and transform back.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=test out=tall ;
  by id1 id2 ;
  var x1 x2 y1 y2 z1 z2 ;
run;

data step2;
  set tall;
  name=substr(_name_,1,length(_name_)-1);
  number = char(_name_,length(_name_));
run;

proc sort data=step2;
  by id1 id2 number name ;
run;

proc transpose data=step2 out=want;
  by id1 id2 number ;
  id name;
  var col1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Parsing your real variable names might be harder.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2022 15:04:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-TRANPOSE-with-quot-multiple-VAR-quot-statements/m-p/820040#M323648</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-23T15:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: PROC TRANPOSE with "multiple VAR" statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-TRANPOSE-with-quot-multiple-VAR-quot-statements/m-p/820222#M323725</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input  (t1 t2 x1 x2 x3 y1 y2 y3 z1 z2 z3) ($);
cards;
xyz xyz 111 222 333 888 999 777 1 2 3
;

proc transpose data=have out=temp;
by t1 t2;
var x1--z3;
run;
data temp;
 set temp;
 id=scan(_name_,1,,'d');
run;
proc sql noprint;
select distinct catt('temp(where=(id="',id,'") rename=(_name_=name_',id,' col1=col_',id,'))') into :merge separated by ' ' from temp;
quit;

data want;
 merge &amp;amp;merge.;
 by t1 t2;
 output;
 call missing(of _all_);
drop id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Jun 2022 12:01:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-TRANPOSE-with-quot-multiple-VAR-quot-statements/m-p/820222#M323725</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-06-24T12:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: PROC TRANPOSE with "multiple VAR" statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-TRANPOSE-with-quot-multiple-VAR-quot-statements/m-p/820226#M323727</link>
      <description>&lt;P&gt;You can use the %UNTRANSPOSE macro&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;ABSTRACT&lt;BR /&gt;PROC TRANSPOSE is an extremely powerful tool for making long files wide, and wide files less wide or&lt;BR /&gt;long, but getting it to do what you need often involves a lot of time, effort, and a substantial knowledge of&lt;BR /&gt;SAS® functions and data step processing. This is especially true when you have to untranspose a wide&lt;BR /&gt;file that contains both character and numeric variables. And, while the procedure usually seamlessly&lt;BR /&gt;handles variable types, lengths and formats, it doesn’t always do that and only creates a system variable&lt;BR /&gt;(i.e., _label_) to capture variable labels. The present paper introduces a macro that simplifies the process,&lt;BR /&gt;significantly reduces the amount of coding and programming skills needed (thus reducing the likelihood of&lt;BR /&gt;producing the wrong result), runs up to 50 or more times faster than the multiple PROC TRANSPOSE&lt;BR /&gt;and data steps that would otherwise be needed, and either creates untransposed variables that inherit all&lt;BR /&gt;of the original variables’ characteristics or creates a file that contains all of the relevant metadata.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2018/2419-2018.pdf" target="_blank"&gt;https://support.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2018/2419-2018.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 12:11:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-TRANPOSE-with-quot-multiple-VAR-quot-statements/m-p/820226#M323727</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-24T12:11:56Z</dc:date>
    </item>
  </channel>
</rss>

