<?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: Concatenating variable value vertically in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-variable-value-vertically/m-p/831758#M328732</link>
    <description>&lt;P&gt;Is this a real-world-problem or something else?&lt;/P&gt;
&lt;P&gt;How does the real data look like?&lt;/P&gt;
&lt;P&gt;Are there three obs always?&lt;/P&gt;</description>
    <pubDate>Mon, 05 Sep 2022 06:49:54 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2022-09-05T06:49:54Z</dc:date>
    <item>
      <title>Concatenating variable value vertically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-variable-value-vertically/m-p/831668#M328681</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a scenario where i have following dataset for example and I want to concatenate variable col2 vertically and get the desired output:&lt;/P&gt;&lt;P&gt;Input table -&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;col1&lt;/TD&gt;&lt;TD&gt;col2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output table:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;col3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;BC&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried following code through self join but not getting the desired output, please if someone could help here:&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table new as&lt;BR /&gt;select cats(a.col2,b.col2) as final&lt;BR /&gt;from old as a left join old as b&lt;BR /&gt;on b.col1=a.col1+1;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2022 16:14:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-variable-value-vertically/m-p/831668#M328681</guid>
      <dc:creator>Brad39</dc:creator>
      <dc:date>2022-09-03T16:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating variable value vertically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-variable-value-vertically/m-p/831679#M328689</link>
      <description>&lt;P&gt;Using basic tools:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
do col1 = 1 to 3;
    col2 = byte(rank("A") + col1 - 1);
    output;
    end;
run;

proc sort data=have; by descending col1; run;

data temp;
set have;
length col3 $16;
retain col3;
col3 = cats(col2, col3);
run;

proc sort data=temp out=want(keep=col3); by col1; run;

proc print data=want; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_0-1662232370195.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/74974iF85A7B2BFBFB31E0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PGStats_0-1662232370195.png" alt="PGStats_0-1662232370195.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2022 19:13:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-variable-value-vertically/m-p/831679#M328689</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2022-09-03T19:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating variable value vertically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-variable-value-vertically/m-p/831758#M328732</link>
      <description>&lt;P&gt;Is this a real-world-problem or something else?&lt;/P&gt;
&lt;P&gt;How does the real data look like?&lt;/P&gt;
&lt;P&gt;Are there three obs always?&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 06:49:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-variable-value-vertically/m-p/831758#M328732</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-09-05T06:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating variable value vertically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenating-variable-value-vertically/m-p/831761#M328734</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input col1 col2 $;
datalines;
1 A
2 B
3 C
;

data want(keep = col3);

   do _N_ = 1 by 1 until (z);
      set have end = z;
      length s $200;
      s = cats(s, col2);
   end;

   do _N_ = 1 to _N_;
      set have;
      col3 = substr(s, _N_);
      output;
   end;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Sep 2022 07:05:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenating-variable-value-vertically/m-p/831761#M328734</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-05T07:05:39Z</dc:date>
    </item>
  </channel>
</rss>

