<?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: Concatenate Row Values and Output List in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Concatenate-Row-Values-and-Output-List/m-p/523625#M4666</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Project_Name $ Ref_No;
datalines;
A 3
A 4
B 9
B 8
C 1
C 2
D 7
;
run;
data want;
length want $ 40;
do until(last.Project_Name); 
 set have;
 by Project_Name;
 want=catx('/',want,Ref_No);
end;
drop Ref_No;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 27 Dec 2018 12:51:33 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2018-12-27T12:51:33Z</dc:date>
    <item>
      <title>Concatenate Row Values and Output List</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Concatenate-Row-Values-and-Output-List/m-p/523616#M4660</link>
      <description>&lt;P&gt;Hi. Can anyone help me on the following?&lt;/P&gt;&lt;P&gt;I'm using SAS EG and trying to use Proc SQL to combine row values as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Project_Name Ref_No&lt;/P&gt;&lt;P&gt;A 3&lt;/P&gt;&lt;P&gt;A 4&lt;/P&gt;&lt;P&gt;B 9&lt;/P&gt;&lt;P&gt;B 8&lt;/P&gt;&lt;P&gt;C 1&lt;/P&gt;&lt;P&gt;C 2&lt;/P&gt;&lt;P&gt;D 7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I want to output a LIST table with the following&lt;/P&gt;&lt;P&gt;Project_Name Ref Nos&lt;/P&gt;&lt;P&gt;A 3/4&lt;/P&gt;&lt;P&gt;B 8/9&lt;/P&gt;&lt;P&gt;C 1/2&lt;/P&gt;&lt;P&gt;D 7&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried this in computed columns advanced expression.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CASE WHEN first.Project_Name THEN '' END&lt;/P&gt;&lt;P&gt;CATX('/',Ref_No,&amp;lt;this variable&amp;gt;)&lt;/P&gt;&lt;P&gt;CASE WHEN last.Project_Name THEN Output&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on another similar query. I also need to do this for two more categorical variables.I'm relatively new to coding in SAS in several years.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 27 Dec 2018 08:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Concatenate-Row-Values-and-Output-List/m-p/523616#M4660</guid>
      <dc:creator>markcat</dc:creator>
      <dc:date>2018-12-27T08:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Row Values and Output List</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Concatenate-Row-Values-and-Output-List/m-p/523618#M4662</link>
      <description>&lt;P&gt;proc sql is not the best tool to solve the problem, in fact i would not even consider to use proc sql. Have you tried using a data-step?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming that the data is sorted by Project_Name:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Project_Name $ Ref_No;
datalines;
A 3
A 4
B 9
B 8
C 1
C 2
D 7
;
run;


data want;
   set have;
   by Project_Name;

   length Ref_Nos $ 50;
   retain Ref_Nos;

   if first.Project_Name then do;
      Ref_Nos = ' ';
   end;

   Ref_Nos = catx('/', Ref_Nos, Ref_No);

   if last.Project_Name then do;
      output;
   end;

   drop Ref_No;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Dec 2018 08:56:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Concatenate-Row-Values-and-Output-List/m-p/523618#M4662</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-12-27T08:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Row Values and Output List</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Concatenate-Row-Values-and-Output-List/m-p/523620#M4663</link>
      <description>&lt;P&gt;alternatively&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Project_Name $ Ref_No;
datalines;
A 3
A 4
B 9
B 8
C 1
C 2
D 7
;
run;

data want;
set have;
by Project_Name;
retain Ref_Nos;
if first.Project_Name then Ref_Nos=strip(put(Ref_No,best.));
else  Ref_Nos=catx('/',Ref_Nos,put(Ref_No,best.));
if last.Project_Name;
drop Ref_No;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Dec 2018 09:22:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Concatenate-Row-Values-and-Output-List/m-p/523620#M4663</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-12-27T09:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Row Values and Output List</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Concatenate-Row-Values-and-Output-List/m-p/523625#M4666</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Project_Name $ Ref_No;
datalines;
A 3
A 4
B 9
B 8
C 1
C 2
D 7
;
run;
data want;
length want $ 40;
do until(last.Project_Name); 
 set have;
 by Project_Name;
 want=catx('/',want,Ref_No);
end;
drop Ref_No;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Dec 2018 12:51:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Concatenate-Row-Values-and-Output-List/m-p/523625#M4666</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-12-27T12:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Row Values and Output List</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Concatenate-Row-Values-and-Output-List/m-p/523629#M4667</link>
      <description>&lt;P&gt;Nice, the only change I would think in your &lt;EM&gt;&lt;STRONG&gt;else&lt;/STRONG&gt;&lt;/EM&gt; is&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt; Ref_Nos&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;catx&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'/'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;Ref_Nos&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;Ref_No&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;best&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;that, the put conversion is redundant if you are using catx.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; Ref_Nos=catx('/',Ref_Nos,Ref_No);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will suffice. Try, replacing your original with the above in your else, run again and notice the log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, best. format defaults to 12 bytes of character as length. You might want to specify a longer length&amp;nbsp; or choose the highest range like best&lt;STRONG&gt;32.&amp;nbsp;&lt;/STRONG&gt; Even then, It's safer to declare a length at compile time to avoid any unforeseen truncation.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Dec 2018 13:18:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Concatenate-Row-Values-and-Output-List/m-p/523629#M4667</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-27T13:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Row Values and Output List</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Concatenate-Row-Values-and-Output-List/m-p/523667#M4677</link>
      <description>&lt;P&gt;You want to produce a data value that depends on row order.&amp;nbsp; I.e. while the ratio you are trying to produce does need to look at 2 rows with the same project_name (which PROC SQL can do for you), you want to&amp;nbsp;put the earlier row value over the later row value.&amp;nbsp; PROC SQL can find and use relations between rows, but not the relative row positions .&amp;nbsp; And you have no third variable that would permit distinguishing between the earlier and later rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is why you are being offered DATA step solutions.&amp;nbsp; Because the data step reads a data set in sequential order, it can allow you to reliably utilize observation (i.e. "row") order.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Dec 2018 17:07:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Concatenate-Row-Values-and-Output-List/m-p/523667#M4677</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-12-27T17:07:48Z</dc:date>
    </item>
  </channel>
</rss>

