<?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 DATA  step  issue in merge in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DATA-step-issue-in-merge/m-p/432806#M281806</link>
    <description>&lt;P&gt;Hello All,&lt;/P&gt;
&lt;P&gt;Below code is not producing the anticipated results&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data temp1;&lt;BR /&gt;input miles cnt Pcode $;&lt;BR /&gt;datalines;&lt;BR /&gt;0 0 BLD&lt;BR /&gt;999999 0 YOS&lt;BR /&gt;999999 24605 MNT&lt;BR /&gt;0 10 MNT&lt;BR /&gt;999999 0 TLP&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data temp2;&lt;BR /&gt;input cnt flg $ Pcode $;&lt;BR /&gt;datalines;&lt;BR /&gt;1 O BLD&lt;BR /&gt;2 N YOS&lt;BR /&gt;3 O MNT&lt;BR /&gt;4 O MNT&lt;BR /&gt;5 N MNT&lt;BR /&gt;6 O SHT&lt;BR /&gt;9 S TLP&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;DATA TEMP3;&lt;BR /&gt;SET temp1 TEMP2;&lt;BR /&gt; if Pcode = 'MNT'; &lt;BR /&gt; if flg = 'O' then miles = 999999;&lt;BR /&gt; RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CNT =5&amp;nbsp; row should not have value of&amp;nbsp;999999 in&amp;nbsp;&lt;STRONG&gt;miles&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt; &amp;nbsp;. It is suppose to be missing.&amp;nbsp; Please let me know your thoughts&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;miles&amp;nbsp; &amp;nbsp; &amp;nbsp; cnt&amp;nbsp; &amp;nbsp; &amp;nbsp;Pcode flg&lt;/STRONG&gt;&lt;BR /&gt;999999&amp;nbsp; 24605 MNT &lt;BR /&gt;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MNT &lt;BR /&gt;999999&amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MNT O&lt;BR /&gt;999999&amp;nbsp; 4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MNT O&lt;BR /&gt;&lt;STRONG&gt;999999&amp;nbsp; 5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MNT N&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 31 Jan 2018 16:27:44 GMT</pubDate>
    <dc:creator>againreddy</dc:creator>
    <dc:date>2018-01-31T16:27:44Z</dc:date>
    <item>
      <title>DATA  step  issue in merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATA-step-issue-in-merge/m-p/432806#M281806</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;
&lt;P&gt;Below code is not producing the anticipated results&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data temp1;&lt;BR /&gt;input miles cnt Pcode $;&lt;BR /&gt;datalines;&lt;BR /&gt;0 0 BLD&lt;BR /&gt;999999 0 YOS&lt;BR /&gt;999999 24605 MNT&lt;BR /&gt;0 10 MNT&lt;BR /&gt;999999 0 TLP&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data temp2;&lt;BR /&gt;input cnt flg $ Pcode $;&lt;BR /&gt;datalines;&lt;BR /&gt;1 O BLD&lt;BR /&gt;2 N YOS&lt;BR /&gt;3 O MNT&lt;BR /&gt;4 O MNT&lt;BR /&gt;5 N MNT&lt;BR /&gt;6 O SHT&lt;BR /&gt;9 S TLP&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;DATA TEMP3;&lt;BR /&gt;SET temp1 TEMP2;&lt;BR /&gt; if Pcode = 'MNT'; &lt;BR /&gt; if flg = 'O' then miles = 999999;&lt;BR /&gt; RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CNT =5&amp;nbsp; row should not have value of&amp;nbsp;999999 in&amp;nbsp;&lt;STRONG&gt;miles&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt; &amp;nbsp;. It is suppose to be missing.&amp;nbsp; Please let me know your thoughts&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;miles&amp;nbsp; &amp;nbsp; &amp;nbsp; cnt&amp;nbsp; &amp;nbsp; &amp;nbsp;Pcode flg&lt;/STRONG&gt;&lt;BR /&gt;999999&amp;nbsp; 24605 MNT &lt;BR /&gt;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MNT &lt;BR /&gt;999999&amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MNT O&lt;BR /&gt;999999&amp;nbsp; 4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MNT O&lt;BR /&gt;&lt;STRONG&gt;999999&amp;nbsp; 5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MNT N&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 16:27:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATA-step-issue-in-merge/m-p/432806#M281806</guid>
      <dc:creator>againreddy</dc:creator>
      <dc:date>2018-01-31T16:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: DATA  step  issue in merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATA-step-issue-in-merge/m-p/432813#M281807</link>
      <description>&lt;P&gt;Variables that come from a SAS data set (such as MILES) are automatically retained.&amp;nbsp; So the MILES value you are noticing (when CNT=4) is retained and appears again on the next observation (when CNT=5).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your purposes, here is a way to code around that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA TEMP3;&lt;BR /&gt;SET temp1 TEMP2 (in=from_TEMP2);&lt;BR /&gt; if Pcode = 'MNT';&lt;/P&gt;
&lt;P&gt;if from_TEMP2 then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if flg = 'O' then miles = 999999;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else miles = .;&lt;/P&gt;
&lt;P&gt;end;&lt;BR /&gt; RUN;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 16:20:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATA-step-issue-in-merge/m-p/432813#M281807</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-01-31T16:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: DATA  step  issue in merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATA-step-issue-in-merge/m-p/432855#M281808</link>
      <description>&lt;H3&gt;&lt;A name="a000290021" target="_blank"&gt;&lt;/A&gt;Redundancy&lt;/H3&gt;
&lt;P&gt;&lt;A name="a000855624" target="_blank"&gt;&lt;/A&gt;It is redundant to name any of these items in a RETAIN statement, because their values are automatically retained from one iteration of the DATA step to the next:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A name="a000855625" target="_blank"&gt;&lt;/A&gt;variables that are read with a SET, MERGE, MODIFY or UPDATE statement&lt;/STRONG&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;A name="a000855626" target="_blank"&gt;&lt;/A&gt;a variable whose value is assigned in a sum statement&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;A name="a000855627" target="_blank"&gt;&lt;/A&gt;the automatic variables _N_, _ERROR_, _I_, _CMD_, and _MSG_&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;A name="a000855628" target="_blank"&gt;&lt;/A&gt;variables that are created by the END= or IN= option in the SET, MERGE, MODIFY, or UPDATE statement or by options that create variables in the FILE and INFILE statements&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;A name="a000855629" target="_blank"&gt;&lt;/A&gt;data elements that are specified in a temporary array&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;A name="a000855630" target="_blank"&gt;&lt;/A&gt;array elements that are initialized in the ARRAY statement&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;A name="a000855631" target="_blank"&gt;&lt;/A&gt;elements of an array that have assigned initial values to any or all of the elements in the ARRAY statement.&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;A name="a000855632" target="_blank"&gt;&lt;/A&gt;You can, however, use a RETAIN statement to assign an initial value to any of the previous items, with the exception of _N_ and _ERROR_.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 18:05:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATA-step-issue-in-merge/m-p/432855#M281808</guid>
      <dc:creator>againreddy</dc:creator>
      <dc:date>2018-01-31T18:05:48Z</dc:date>
    </item>
  </channel>
</rss>

