<?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 with adding character for missing values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709978#M218460</link>
    <description>&lt;P&gt;have&lt;/P&gt;
&lt;P&gt;col1&amp;nbsp; &amp;nbsp; col2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;col3&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;want&lt;/P&gt;
&lt;P&gt;col4&lt;/P&gt;
&lt;P&gt;1/2/Y&lt;/P&gt;
&lt;P&gt;1/3/2&lt;/P&gt;
&lt;P&gt;2/1/3&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jan 2021 17:59:35 GMT</pubDate>
    <dc:creator>noda6003</dc:creator>
    <dc:date>2021-01-07T17:59:35Z</dc:date>
    <item>
      <title>concatenate with adding character for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709948#M218443</link>
      <description>&lt;P&gt;I want to concatente 3 variables and if i have missing varaible at end than want to replace it with "Y".&lt;/P&gt;
&lt;P&gt;Can anyone help me how to do it?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 16:44:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709948#M218443</guid>
      <dc:creator>noda6003</dc:creator>
      <dc:date>2021-01-07T16:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate with adding character for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709951#M218445</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240711"&gt;@noda6003&lt;/a&gt;&amp;nbsp; Can you please post a sample of HAVE and WANT(expected output) explaining the logic?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 17:00:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709951#M218445</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2021-01-07T17:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate with adding character for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709952#M218446</link>
      <description>&lt;P&gt;the easiest way to do what you are doing is to update the table to y where value=null. to concantenate, you would want to use the cat function of which there are many varieties like cat-s, cat-t...here is a webpage on using the cat function...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A title="SAS CAT-S Function" href="https://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#n1e21rr6al5m2nn19r1fat5qxwrt.htm" target="_self"&gt;SAS CAT-S Function&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;an example would be...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; new_var=catx('',var1,var2,var3);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;that is the data step version.&amp;nbsp; i work more in proc sql.&amp;nbsp; i can give you an example of that if you want but that should work.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 17:02:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709952#M218446</guid>
      <dc:creator>me55</dc:creator>
      <dc:date>2021-01-07T17:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate with adding character for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709964#M218455</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240711"&gt;@noda6003&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;has requested, it really helps to see the data, including data types.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In principle, the following logic might be a good starting point:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* set up data in "have" data set */
data have;
   infile datalines truncover;

   input
      var1 : $char1.
      var2 : $char1.
      var3 : $char1.
   ;

   datalines;
a b c
d e  
g h i
;

/* create data in "want" data set based on "have" data set */
data want;
   set have;
   length result $ 3;

   /* if var3 is missing then use "Y" otherwise use var3 */
   result = cats(var1,var2,ifc(missing(var3),'Y',var3));
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The processing in the 2nd data step should also work for numeric input variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this is not what you want then please provide example data and logic as requested.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 17:25:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709964#M218455</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2021-01-07T17:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate with adding character for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709969#M218458</link>
      <description>&lt;P&gt;Please show the code you are using to concatenate the variables.&lt;/P&gt;
&lt;P&gt;I suspect you can replace one of the variables with : coalescec(varname,'Y')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The coalescec function returns the first non-missing value in a list of character values be they variables or literals.&lt;/P&gt;
&lt;P&gt;Coalesce does the same thing for numeric values.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 17:33:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709969#M218458</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-07T17:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate with adding character for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709978#M218460</link>
      <description>&lt;P&gt;have&lt;/P&gt;
&lt;P&gt;col1&amp;nbsp; &amp;nbsp; col2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;col3&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;want&lt;/P&gt;
&lt;P&gt;col4&lt;/P&gt;
&lt;P&gt;1/2/Y&lt;/P&gt;
&lt;P&gt;1/3/2&lt;/P&gt;
&lt;P&gt;2/1/3&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 17:59:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709978#M218460</guid>
      <dc:creator>noda6003</dc:creator>
      <dc:date>2021-01-07T17:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate with adding character for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709981#M218462</link>
      <description>&lt;P&gt;I use&amp;nbsp; ct = cats("/",col1,col2,ifc(missing(col3),'Y',col3));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it does not work&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 18:06:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709981#M218462</guid>
      <dc:creator>noda6003</dc:creator>
      <dc:date>2021-01-07T18:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate with adding character for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709982#M218463</link>
      <description>&lt;P&gt;The CAT... functions will honor the MISSING option setting.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input col1-col3 ;
cards;
1          2            .
1          3           2
2          1           3
;

options missing='Y';
data want;
  set have;
  want=catx('/', of col1-col3);
run;
options missing='.';

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    col1    col2    col3    want

 1       1       2       .     1/2/Y
 2       1       3       2     1/3/2
 3       2       1       3     2/1/3
&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Jan 2021 18:10:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709982#M218463</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-07T18:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate with adding character for missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709983#M218464</link>
      <description>&lt;P&gt;good attempt&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240711"&gt;@noda6003&lt;/a&gt;&amp;nbsp; just a tweak-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input var1-var3;
 cards;
1          2            .

1          3           2

2          1           3
;

data want;
 set have;
 length want $10;
 want=catx('/',var1,var2,ifc(var3=.,'Y',put(var3,8.)));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Jan 2021 18:12:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-with-adding-character-for-missing-values/m-p/709983#M218464</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2021-01-07T18:12:59Z</dc:date>
    </item>
  </channel>
</rss>

