<?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 combine only when the value is missing in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-combine-only-when-the-value-is-missing/m-p/327100#M72943</link>
    <description>&lt;P&gt;Use a CASE statement as show in below sample code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select 
case 
when CODE1 = ' ' then CODEB1 else CODE1 end as CODE1
from test ;
quit ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 24 Jan 2017 16:13:57 GMT</pubDate>
    <dc:creator>anoopmohandas7</dc:creator>
    <dc:date>2017-01-24T16:13:57Z</dc:date>
    <item>
      <title>how to combine only when the value is missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-combine-only-when-the-value-is-missing/m-p/327074#M72930</link>
      <description>&lt;P&gt;Hi Professionals,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a simple sample for my tables.&lt;/P&gt;&lt;P&gt;the original one is like:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;APPLICATION&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;CODE1&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;CODE2&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;CODEB1&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;CODEB2&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt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gt;&lt;TD&gt;&lt;STRONG&gt;CODE1&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;CODE2&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1111&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;S&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1112&lt;/TD&gt;&lt;TD&gt;N&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1113&lt;/TD&gt;&lt;TD&gt;CF&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1114&lt;/TD&gt;&lt;TD&gt;B&amp;lt;40&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1115&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;S&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1116&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;For each application, when code1 ='' and code2='' &amp;nbsp;let code1=codeb1&amp;nbsp;and code2=codeb2. for the rest code 1 or code2, just keep their original value.&lt;/P&gt;&lt;P&gt;then delete codeb1 and codeb2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I do the merge?&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;set origianl;&lt;/P&gt;&lt;P&gt;if code1='' and code2='' then code1=codeb1 and code2=codeb2;&lt;/P&gt;&lt;P&gt;else (here I dont' know how to describe let codes = original value);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for anyone who helps.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 15:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-combine-only-when-the-value-is-missing/m-p/327074#M72930</guid>
      <dc:creator>septemberbulb</dc:creator>
      <dc:date>2017-01-24T15:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to combine only when the value is missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-combine-only-when-the-value-is-missing/m-p/327079#M72931</link>
      <description>&lt;P&gt;You are actually most of the way there. What you are missing in concept is if the values are not both missing then you are actually saying "do nothing, leave it alone". However you can only have one assignment per statement so you have to assign the values of code1 and code2 separately. To make them respond to the same condition then use a DO; End; block to group them.&lt;/P&gt;
&lt;P&gt;You want to drop the extra variables or alternatively use KEEP to keep the ones you want.&lt;/P&gt;
&lt;P&gt;So&lt;/P&gt;
&lt;P&gt;data new;&lt;/P&gt;
&lt;P&gt;set origianl;&lt;/P&gt;
&lt;P&gt;if code1='' and code2='' then Do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; code1=codeb1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; code2=codeb2;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop codeb1 codeb2;&lt;/P&gt;
&lt;P&gt;/* or Keep application code1 code2;*/&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 15:27:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-combine-only-when-the-value-is-missing/m-p/327079#M72931</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-24T15:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to combine only when the value is missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-combine-only-when-the-value-is-missing/m-p/327081#M72932</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd just use the coalesce function to get what you want:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines dsd;
input APPLICATION CODE1 $ CODE2 $ CODEB1 $ CODEB2 $;
datalines;
1111, F, S, F, S
1112, N,  , N,  
1113, CF,  , CF,  
1114,  ,  , B&amp;lt;40,  
1115,  ,  , F, S
1116,  ,  , F,  
;


data want;
    set have;
    code1 = coalescec(code1, codeb1);
    code2 = coalescec(code2, codeb2);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Jan 2017 15:34:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-combine-only-when-the-value-is-missing/m-p/327081#M72932</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-01-24T15:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to combine only when the value is missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-combine-only-when-the-value-is-missing/m-p/327084#M72934</link>
      <description>&lt;P&gt;I think my solution works with the&amp;nbsp;data, but not with the&amp;nbsp;description. The above addresses the problem described better, I think.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 15:45:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-combine-only-when-the-value-is-missing/m-p/327084#M72934</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-01-24T15:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to combine only when the value is missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-combine-only-when-the-value-is-missing/m-p/327094#M72940</link>
      <description>THANK YOU VERY MUCH.</description>
      <pubDate>Tue, 24 Jan 2017 16:03:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-combine-only-when-the-value-is-missing/m-p/327094#M72940</guid>
      <dc:creator>septemberbulb</dc:creator>
      <dc:date>2017-01-24T16:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to combine only when the value is missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-combine-only-when-the-value-is-missing/m-p/327095#M72941</link>
      <description>thank you</description>
      <pubDate>Tue, 24 Jan 2017 16:03:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-combine-only-when-the-value-is-missing/m-p/327095#M72941</guid>
      <dc:creator>septemberbulb</dc:creator>
      <dc:date>2017-01-24T16:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to combine only when the value is missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-combine-only-when-the-value-is-missing/m-p/327100#M72943</link>
      <description>&lt;P&gt;Use a CASE statement as show in below sample code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select 
case 
when CODE1 = ' ' then CODEB1 else CODE1 end as CODE1
from test ;
quit ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Jan 2017 16:13:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-combine-only-when-the-value-is-missing/m-p/327100#M72943</guid>
      <dc:creator>anoopmohandas7</dc:creator>
      <dc:date>2017-01-24T16:13:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to combine only when the value is missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-combine-only-when-the-value-is-missing/m-p/327129#M72953</link>
      <description>thank you</description>
      <pubDate>Tue, 24 Jan 2017 18:21:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-combine-only-when-the-value-is-missing/m-p/327129#M72953</guid>
      <dc:creator>septemberbulb</dc:creator>
      <dc:date>2017-01-24T18:21:19Z</dc:date>
    </item>
  </channel>
</rss>

