<?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 How to append variables? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-append-variables/m-p/199146#M49749</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data I have is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="256"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" width="64"&gt;ID&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="64"&gt;Score1 &lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="64"&gt;Score2&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="64"&gt;Score3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border-top: none;"&gt;A&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;5&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border-top: none;"&gt;B&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border-top: none;"&gt;C&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;9&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;6&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to convert it as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="128"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" width="64"&gt;ID&lt;/TD&gt;&lt;TD class="xl65" width="64"&gt;Score&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;A&lt;/TD&gt;&lt;TD class="xl65"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;C&lt;/TD&gt;&lt;TD class="xl65"&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;A&lt;/TD&gt;&lt;TD class="xl65"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;C&lt;/TD&gt;&lt;TD class="xl65"&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;A&lt;/TD&gt;&lt;TD class="xl65"&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;C&lt;/TD&gt;&lt;TD class="xl65"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The way I'm doing it pretty crude:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have (keep = id score1 rename=(score1=score)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 13.3333330154419px;"&gt;have (keep = id score2 rename=(score2=score)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 13.3333330154419px;"&gt;have (keep = id score3 rename=(score3=score);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;This could be tedious with say 50 variables. Is there any sophisticated way? Can proc transpose handle this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;P&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Mar 2015 15:08:12 GMT</pubDate>
    <dc:creator>pmesh</dc:creator>
    <dc:date>2015-03-11T15:08:12Z</dc:date>
    <item>
      <title>How to append variables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-append-variables/m-p/199146#M49749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data I have is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="256"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" width="64"&gt;ID&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="64"&gt;Score1 &lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="64"&gt;Score2&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="64"&gt;Score3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border-top: none;"&gt;A&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;5&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border-top: none;"&gt;B&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border-top: none;"&gt;C&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;9&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;6&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to convert it as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="128"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" width="64"&gt;ID&lt;/TD&gt;&lt;TD class="xl65" width="64"&gt;Score&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;A&lt;/TD&gt;&lt;TD class="xl65"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;C&lt;/TD&gt;&lt;TD class="xl65"&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;A&lt;/TD&gt;&lt;TD class="xl65"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;C&lt;/TD&gt;&lt;TD class="xl65"&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;A&lt;/TD&gt;&lt;TD class="xl65"&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;B&lt;/TD&gt;&lt;TD class="xl65"&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;C&lt;/TD&gt;&lt;TD class="xl65"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The way I'm doing it pretty crude:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have (keep = id score1 rename=(score1=score)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 13.3333330154419px;"&gt;have (keep = id score2 rename=(score2=score)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 13.3333330154419px;"&gt;have (keep = id score3 rename=(score3=score);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;This could be tedious with say 50 variables. Is there any sophisticated way? Can proc transpose handle this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;P&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 15:08:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-append-variables/m-p/199146#M49749</guid>
      <dc:creator>pmesh</dc:creator>
      <dc:date>2015-03-11T15:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to append variables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-append-variables/m-p/199147#M49750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One option would be to create the list of input datasets automatically with a macro loop. proc transpose would (IMHO) not be able to create your A,B,C,A,B,C order. It would rather give you A,A,A,B,B,B,C,C,C instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the order of output records doe not matter, usage of an array and looping through that would also come to mind.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 15:17:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-append-variables/m-p/199147#M49750</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-03-11T15:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to append variables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-append-variables/m-p/199148#M49751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reply. No, order is not important here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 15:23:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-append-variables/m-p/199148#M49751</guid>
      <dc:creator>pmesh</dc:creator>
      <dc:date>2015-03-11T15:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to append variables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-append-variables/m-p/199149#M49752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile datalines;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input ID $ Score1 Score2 Score3;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;A 5 2 8&lt;/P&gt;&lt;P&gt;B 4 3 7&lt;/P&gt;&lt;P&gt;C 9 6 1&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set sashelp.vcolumn (where=(libname="WORK" and memname="HAVE" and substr(name,1,5)="Score")) end=last;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then call execute('data want; set ');&lt;/P&gt;&lt;P&gt;&amp;nbsp; call execute(' work.have (keep=id '||strip(name)||' rename=('||strip(name)||'=Score))');&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last then call execute(';run;');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 15:28:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-append-variables/m-p/199149#M49752</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-03-11T15:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to append variables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-append-variables/m-p/199150#M49753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi - thanks for being part of Communities on SAS - I noticed this question was asked in the "about communities on SAS" community .. just for greater visibility I'm moving it to the SAS procedures community. Best regards!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 15:49:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-append-variables/m-p/199150#M49753</guid>
      <dc:creator>Community_Help</dc:creator>
      <dc:date>2015-03-11T15:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to append variables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-append-variables/m-p/199151#M49754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Then do the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (keep=id score);&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;array scores {} score1-score3; * or use _numeric_ if all numeric variables are to be taken for output;&lt;/P&gt;&lt;P&gt;do i = 1 to dim(scores);&lt;/P&gt;&lt;P&gt;&amp;nbsp; score = scores{i};&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 15:50:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-append-variables/m-p/199151#M49754</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-03-11T15:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to append variables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-append-variables/m-p/199152#M49755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Superb. Worked perfectly!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 16:35:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-append-variables/m-p/199152#M49755</guid>
      <dc:creator>pmesh</dc:creator>
      <dc:date>2015-03-11T16:35:35Z</dc:date>
    </item>
  </channel>
</rss>

