<?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 transpose repeatly? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367757#M64941</link>
    <description>&lt;P&gt;No, some of them are numeric and some of them are charater.&lt;/P&gt;</description>
    <pubDate>Fri, 16 Jun 2017 15:22:36 GMT</pubDate>
    <dc:creator>ybz12003</dc:creator>
    <dc:date>2017-06-16T15:22:36Z</dc:date>
    <item>
      <title>proc transpose repeatly?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367754#M64938</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have&amp;nbsp;10 very similar proc transpose programs.&amp;nbsp; Is there a way to simply them?&amp;nbsp; Maybe a macro or do loop something?&amp;nbsp; The oringal data set is shown in the attachment&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;transpose&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=test &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=trans3&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;prefix&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=TAN;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;var&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; TAN_1-TAN_3;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ID Name; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;transpose&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=test &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=trans4&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;prefix&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=CAN;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;var&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; CAN_1-CAN_5;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ID Name; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;transpose&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=test &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=trans5&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;prefix&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=ROOD;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;var&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ROOD_1-ROOD_8;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ID Name; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 11:24:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367754#M64938</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-20T11:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose repeatly?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367755#M64939</link>
      <description>&lt;P&gt;you could try the arrays please find an untested code&lt;/P&gt;
&lt;P&gt;, the below program i wrote where i considered the tab can and rood variables are numeric. So in want we get the newvar numeric variable.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array vars(*) tan_1-tan_3 can_1-can_5 rood_1-rood_8;
do i = 1 to dim(vars);
if vars(i) ne . then newvar=vars(i);
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Jun 2017 15:19:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367755#M64939</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-06-16T15:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose repeatly?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367757#M64941</link>
      <description>&lt;P&gt;No, some of them are numeric and some of them are charater.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 15:22:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367757#M64941</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-16T15:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose repeatly?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367759#M64942</link>
      <description>may i know which are numeric and which are character</description>
      <pubDate>Fri, 16 Jun 2017 15:26:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367759#M64942</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-06-16T15:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose repeatly?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367760#M64943</link>
      <description>&lt;P&gt;This will save some space. I use this structure when I have repeated procedures in a code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro trans(i, pre, var_num);

  proc transpose data=test out=trans&amp;amp;i. prefix=&amp;amp;pre.;
    var &amp;amp;pre._1-&amp;amp;pre._&amp;amp;var_num.;
    by ID Name;
    run; quit;

%mend;

%trans(i=1, pre=TAN, var_num=3);
%trans(i=2, pre=CAN, var_num=5);
%trans(i=3, pre=ROOD, var_num=8);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Jun 2017 15:28:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367760#M64943</guid>
      <dc:creator>Rwon</dc:creator>
      <dc:date>2017-06-16T15:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose repeatly?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367773#M64944</link>
      <description>&lt;P&gt;Show the input and desired final output.&lt;/P&gt;
&lt;P&gt;I have a suspicion you are combining the resulting sets and we really should see what that result should be.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 15:58:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367773#M64944</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-16T15:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose repeatly?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367787#M64945</link>
      <description>&lt;P&gt;I have attached the dataset on the first message.&amp;nbsp; You're right.&amp;nbsp; I did plan to combine all of dataset after transpose.&amp;nbsp; Is there going to be a problem when the dataset is not in the same format?&amp;nbsp; I plan to use&amp;nbsp;proc sql.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 16:28:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367787#M64945</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-16T16:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose repeatly?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367798#M64946</link>
      <description>&lt;P&gt;As long as you do not care that your numeric variables are converted to character and back to numeric you can perhaps just process all of them with two proc transpose calls and a little more work in between.&lt;/P&gt;
&lt;P&gt;First make a tall skinny table and then parse the names into prefix and numeric suffix.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=middle ;
  by id name ;
  var tan: can: ;
run;

data fix_middle ;
  set middle ;
  row = input(scan(_name_,2,'_'),32.);
  _name_=scan(_name_,1,'_');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then resort to mark the rows match-up and transpose again.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort;
  by id name row _name_;
run;

proc transpose data=fix_middle out=want ;
  by id name row ;
  id _name_;
  var col1 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now add a step to convert the numeric variables back.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fix_want ;
  set want ;
  tan_num = input(tan,??32.);
  rename tan_num=tan ;
  drop _name_ tan ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/9456i3811E6572F2A03EF/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 16:51:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367798#M64946</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-16T16:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose repeatly?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367800#M64947</link>
      <description>&lt;P&gt;That is awesome.&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 16:54:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367800#M64947</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-16T16:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose repeatly?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367802#M64948</link>
      <description>&lt;P&gt;Thank you so much. Great idea, Tom.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 16:56:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-repeatly/m-p/367802#M64948</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-16T16:56:53Z</dc:date>
    </item>
  </channel>
</rss>

