<?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: Any help to get expected results ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Any-help-to-get-expected-results/m-p/773244#M245607</link>
    <description>&lt;P&gt;Below building on the code you provided.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data e;
  input cycle tot1 tot2;
  cards;
205 10 30
205 20 40
;

data f;
  infile cards missover;
  input cycle tot1;
  cards;
205 .
205 50
;

/* option 1: coalesce() will pick the first non-missining value */
data g_1;
  merge e(in=a) f(rename=(tot1=_tot1));
  tot1=coalesce(_tot1,tot1);
  drop _tot1;
run;

/* option 2: if _tot1 not missing then use it to populate tot1 */
data g_2;
  merge e(in=a) f(rename=(tot1=_tot1));
  if _tot1 ne . then tot1=_tot1;
  drop _tot1;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 10 Oct 2021 02:52:40 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2021-10-10T02:52:40Z</dc:date>
    <item>
      <title>Any help to get expected results ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Any-help-to-get-expected-results/m-p/773243#M245606</link>
      <description>&lt;P&gt;I have two datasets, e and f.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data e;&lt;BR /&gt;input cycle tot1 tot2;&lt;BR /&gt;cards;&lt;BR /&gt;205 10 30&lt;BR /&gt;205 20 40&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data f;&lt;BR /&gt;infile cards missover;&lt;BR /&gt;input cycle tot1 ;&lt;BR /&gt;cards;&lt;BR /&gt;205 . &lt;BR /&gt;205 50 &lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The expected dataset would be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cycle tot1 tot2&lt;BR /&gt;205 10 30&lt;BR /&gt;205 50 40&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;
&lt;P&gt;Test code :&lt;/P&gt;
&lt;P&gt;data g;&lt;BR /&gt;merge e(in=a) f(rename=(tot1=t1 tot2=t2));&lt;BR /&gt;by cycle;&lt;BR /&gt;array t(2) t1-t2;&lt;BR /&gt;array tot(2) tot1-tot2;&lt;BR /&gt;do i=1 to 2;&lt;BR /&gt;if t(i)^= . then tot(i)=t(i);&amp;nbsp;&lt;BR /&gt;end;&lt;BR /&gt;if a ;&lt;BR /&gt;drop t1 t2 i;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Oct 2021 01:49:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Any-help-to-get-expected-results/m-p/773243#M245606</guid>
      <dc:creator>GPatel</dc:creator>
      <dc:date>2021-10-10T01:49:34Z</dc:date>
    </item>
    <item>
      <title>Re: Any help to get expected results ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Any-help-to-get-expected-results/m-p/773244#M245607</link>
      <description>&lt;P&gt;Below building on the code you provided.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data e;
  input cycle tot1 tot2;
  cards;
205 10 30
205 20 40
;

data f;
  infile cards missover;
  input cycle tot1;
  cards;
205 .
205 50
;

/* option 1: coalesce() will pick the first non-missining value */
data g_1;
  merge e(in=a) f(rename=(tot1=_tot1));
  tot1=coalesce(_tot1,tot1);
  drop _tot1;
run;

/* option 2: if _tot1 not missing then use it to populate tot1 */
data g_2;
  merge e(in=a) f(rename=(tot1=_tot1));
  if _tot1 ne . then tot1=_tot1;
  drop _tot1;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 10 Oct 2021 02:52:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Any-help-to-get-expected-results/m-p/773244#M245607</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-10-10T02:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: Any help to get expected results ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Any-help-to-get-expected-results/m-p/773261#M245614</link>
      <description>&lt;PRE&gt;data e;
  input cycle tot1 tot2;
  n+1;
  cards;
205 10 30
205 20 40
;

data f;
  infile cards missover;
  input cycle tot1;
  n+1;
  cards;
205 .
205 50
;

data want;
 update  e f;
 by cycle n;
 drop n;
run;&lt;/PRE&gt;</description>
      <pubDate>Sun, 10 Oct 2021 10:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Any-help-to-get-expected-results/m-p/773261#M245614</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-10-10T10:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: Any help to get expected results ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Any-help-to-get-expected-results/m-p/773880#M245907</link>
      <description>&lt;P&gt;Patric and KSharp:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks to both of you for providing excellent solution. I appreciate your time and interest and service to SAS Community.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;GPatel&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 10:29:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Any-help-to-get-expected-results/m-p/773880#M245907</guid>
      <dc:creator>GPatel</dc:creator>
      <dc:date>2021-10-13T10:29:25Z</dc:date>
    </item>
  </channel>
</rss>

