<?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: Conditional replacement of missing value with adjacent similar transaction in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/322679#M71412</link>
    <description>sorry a small change, please try the below code &lt;BR /&gt;remove the descending site_id from update statement code.&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;update have(obs=0) have;&lt;BR /&gt;by name service_date ;&lt;BR /&gt;output;&lt;BR /&gt;run;</description>
    <pubDate>Thu, 05 Jan 2017 15:16:33 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2017-01-05T15:16:33Z</dc:date>
    <item>
      <title>Conditional replacement of missing value with adjacent similar transaction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/320933#M70763</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having a data consisting of multiple transactions for a person within a same day but some of the records for the same person is missing e.g site ID. I want to fill the missing site ID by taking value from one of the site ID from the transactions of that person on the same date assuming that in a day all transaction occurs in one site only. Can some one kindly help me to move forward.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name $ service_date site_ID ;
cards;
aaa 20140102 101
aaa 20140102    
bbb 20140102 102
ccc 20140104 103
ccc 20140104    
ccc 20140104 103
aaa 20140105 104
aaa 20140105    
aaa 20140105 104
;
run;




data want;
input name $ service_date site_ID ;
cards;
aaa 20140102 101
aaa 20140102 101
bbb 20140102 102
ccc 20140104 103
ccc 20140104 103
ccc 20140104 103
aaa 20140105 104
aaa 20140105 104
aaa 20140105 104
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your kind reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2016 14:27:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/320933#M70763</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2016-12-23T14:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional replacement of missing value with adjacent similar transaction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/320935#M70764</link>
      <description>&lt;P&gt;Please check the site_id2 variable with expected result&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by name service_date;
run;

data want;
set have;
retain site_id2;
by name service_date;
if first.service_date then site_id2=site_id;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Dec 2016 14:41:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/320935#M70764</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2016-12-23T14:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional replacement of missing value with adjacent similar transaction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/320937#M70766</link>
      <description>Hi Jagadish,&lt;BR /&gt;Thanks for your quick reply.&lt;BR /&gt;Regards,</description>
      <pubDate>Fri, 23 Dec 2016 14:51:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/320937#M70766</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2016-12-23T14:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional replacement of missing value with adjacent similar transaction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/321012#M70796</link>
      <description>&lt;P&gt;What if the first record for a given date has a missing site?&amp;nbsp; This program would propagate that missing value to all records for the given date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2016 23:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/321012#M70796</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-12-23T23:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional replacement of missing value with adjacent similar transaction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/322665#M71402</link>
      <description>&lt;P&gt;Hi Mkeintz&lt;SPAN class="login-bold"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Unfortunately I am experiencing the issue mentioned by you in your comment. Can you advice me further to overcome the impact of missing first record for a given date.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Thank you in advance for your kind reply. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Regards,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 14:25:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/322665#M71402</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2017-01-05T14:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional replacement of missing value with adjacent similar transaction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/322668#M71404</link>
      <description>&lt;P&gt;for your query, i considered the scenario you mentioned. We could avoid the same by changing the sorting order of the site_id, we need to ensure that the non missing site_id comes first and the same could be retained to other records. This time I used the update statement to achieve the expected output along with the proc sort step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards missover;
input name $ @5 service_date site_ID ;
cards;
aaa 20140102    
aaa 20140102 101
bbb 20140102 102
ccc 20140104 103
ccc 20140104    
ccc 20140104 103
aaa 20140105 104
aaa 20140105    
aaa 20140105 104
;
run;

proc sort data=have;
by name service_date descending site_ID;
run;

data want;
update have(obs=0) have;
by name service_date descending site_ID;
output;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Jan 2017 14:37:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/322668#M71404</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-01-05T14:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional replacement of missing value with adjacent similar transaction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/322675#M71410</link>
      <description>&lt;P&gt;Hi Jag,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once again thank you for your superfast incredible reply. Just extending the "sorting part" of the solution advised by you, helped to achieve the expected solution using retain statement as before.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In order to increase my knowledge base, I am curious to know the solution based on update statement. Can you review the update statement part as following its use, I am not getting expected result. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your kind reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 15:08:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/322675#M71410</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2017-01-05T15:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional replacement of missing value with adjacent similar transaction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/322679#M71412</link>
      <description>sorry a small change, please try the below code &lt;BR /&gt;remove the descending site_id from update statement code.&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;update have(obs=0) have;&lt;BR /&gt;by name service_date ;&lt;BR /&gt;output;&lt;BR /&gt;run;</description>
      <pubDate>Thu, 05 Jan 2017 15:16:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/322679#M71412</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-01-05T15:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional replacement of missing value with adjacent similar transaction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/322683#M71413</link>
      <description>&lt;P&gt;Hi Jag,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your kind patience in replying my queries. Your advice worked to provide me expected outcome.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 15:25:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/322683#M71413</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2017-01-05T15:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional replacement of missing value with adjacent similar transaction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/322730#M71431</link>
      <description>&lt;P&gt;Why not keep the basic structure of the program, but read the data in two parallel streams, one for site_id missing and one for the rest?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;&amp;nbsp; set have (where=(site_id^=.)) have (where=(site_id=.));&lt;BR /&gt;&amp;nbsp; retain site_id2;&lt;BR /&gt;&amp;nbsp; by name service_date;&lt;BR /&gt;if first.service_date then site_id2=site_id;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 17:29:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/322730#M71431</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-01-05T17:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional replacement of missing value with adjacent similar transaction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/323075#M71558</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN class="login-bold"&gt;Mkeintz,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Thanks for providing an alternative approach.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Deepak&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 20:05:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-replacement-of-missing-value-with-adjacent-similar/m-p/323075#M71558</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2017-01-06T20:05:02Z</dc:date>
    </item>
  </channel>
</rss>

