<?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: How to concatenate multiple rows when they satisfy in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-concatenate-multiple-rows-when-they-satisfy/m-p/562941#M10809</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;got it thank you so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote my code as: "col10=catx('; ',ifc(crit1fl2='N','',crit2),ifc(crit1fl='N','',crit1),ifc(crit1fl3='N','',crit3),&lt;BR /&gt;ifc(crit1fl4='N','',crit4),ifc(crit1fl5='N','',crit5));"&lt;/P&gt;</description>
    <pubDate>Fri, 31 May 2019 17:57:00 GMT</pubDate>
    <dc:creator>chinna0369</dc:creator>
    <dc:date>2019-05-31T17:57:00Z</dc:date>
    <item>
      <title>How to concatenate multiple rows when they satisfy</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-concatenate-multiple-rows-when-they-satisfy/m-p/562920#M10806</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my data:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="snip 1.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29921i381A42643621E237/image-size/large?v=v2&amp;amp;px=999" role="button" title="snip 1.PNG" alt="snip 1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if the values are "Y" then I want to concatenate respective value for those variables?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there any function to do this in a single line?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Adithya&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 17:08:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-concatenate-multiple-rows-when-they-satisfy/m-p/562920#M10806</guid>
      <dc:creator>chinna0369</dc:creator>
      <dc:date>2019-05-31T17:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate multiple rows when they satisfy</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-concatenate-multiple-rows-when-they-satisfy/m-p/562931#M10807</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is there any function to do this in a single line?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Adithya&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Incomplete description though. Do you want a delimiter between your values or do you want text that ends up with the word at the end of one phrase running into the start of the next?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also it is not exactly clear which of the Y valued variables&amp;nbsp;are associated with which of the Crit1 to crit5. The names are 1) not in the same order as the Crit, and with the names like CRIT1FL4 I cannot tell if that should be used with Crit1 or Crit4, especially because you do not have a CRIT1FL1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The example below may get you started. I am placing a ; between values&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   newvar = catx(';',ifc(var1='Y',crit1,''),ifc(var2='Y',crit2,''), 
       /* continue the obvious pattern until you run out of values*/
       );
run;&lt;/PRE&gt;
&lt;P&gt;HOWEVER, since NONE of you values for Crit1 to Crit4 appear to change you might be better off just assigning custom formats to the Y valued variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And just for curiosity sake, how exactly do you intend to use that concatenated variable???&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 17:25:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-concatenate-multiple-rows-when-they-satisfy/m-p/562931#M10807</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-31T17:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate multiple rows when they satisfy</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-concatenate-multiple-rows-when-they-satisfy/m-p/562937#M10808</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your quick response!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for that I am not clear below.&lt;/P&gt;&lt;P&gt;here are my answers to your questions:&lt;/P&gt;&lt;P&gt;1. I want delimeter '; '.&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;crit1fl value is crit1,&amp;nbsp;crit1fl2 value is crit2,&amp;nbsp;crit1fl3 value is crit 3, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as per your post I wrote like below:&lt;/P&gt;&lt;P&gt;col10=catx('; ',ifc(crit1fl2='Y',crit2,''),ifc(crit1fl='Y',crit1,''),ifc(crit1fl3='Y',crit3,''),&lt;BR /&gt;ifc(crit1fl4='Y',crit4,''),ifc(crit1fl5='Y',crit5,''));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I am getting warning as below:&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Snip 2.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29923iAD7A59A27B929C79/image-size/large?v=v2&amp;amp;px=999" role="button" title="Snip 2.PNG" alt="Snip 2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 17:35:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-concatenate-multiple-rows-when-they-satisfy/m-p/562937#M10808</guid>
      <dc:creator>chinna0369</dc:creator>
      <dc:date>2019-05-31T17:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate multiple rows when they satisfy</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-concatenate-multiple-rows-when-they-satisfy/m-p/562941#M10809</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;got it thank you so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote my code as: "col10=catx('; ',ifc(crit1fl2='N','',crit2),ifc(crit1fl='N','',crit1),ifc(crit1fl3='N','',crit3),&lt;BR /&gt;ifc(crit1fl4='N','',crit4),ifc(crit1fl5='N','',crit5));"&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 17:57:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-concatenate-multiple-rows-when-they-satisfy/m-p/562941#M10809</guid>
      <dc:creator>chinna0369</dc:creator>
      <dc:date>2019-05-31T17:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate multiple rows when they satisfy</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-concatenate-multiple-rows-when-they-satisfy/m-p/563020#M10828</link>
      <description>&lt;P&gt;If you are assigning to a&amp;nbsp; variable with a defined length shorter than the result of the CATX function you might get that message. It is generally a good idea to specify a LENGTH for a variable before use long enough to hold the longest expected value before actual use in the code.&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 20:59:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-concatenate-multiple-rows-when-they-satisfy/m-p/563020#M10828</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-31T20:59:07Z</dc:date>
    </item>
  </channel>
</rss>

