<?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 map to the previous variable value?? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-map-to-the-previous-variable-value/m-p/283694#M57831</link>
    <description>&lt;P&gt;Or more simple :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set have;
 if X ne 999 then Y=X;
  else Y+0.1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 12 Jul 2016 06:54:00 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-07-12T06:54:00Z</dc:date>
    <item>
      <title>how to map to the previous variable value??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-map-to-the-previous-variable-value/m-p/283687#M57826</link>
      <description>&lt;P&gt;can anyone answer this query??&lt;/P&gt;&lt;P&gt;there is a input variable called X. need to derive variable called 'Y'.. the scenario is wherever there is 999 value there it has to add 0.1 to the previous x value.. if more than one 999 is there then the order should be 3.1, 3.2,3.3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;X &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;BR /&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;BR /&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4&lt;BR /&gt;999 &amp;nbsp; &amp;nbsp;4.1&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;BR /&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;BR /&gt;999 &amp;nbsp; &amp;nbsp;3.1&lt;BR /&gt;999 &amp;nbsp; &amp;nbsp;3.2&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2016 06:08:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-map-to-the-previous-variable-value/m-p/283687#M57826</guid>
      <dc:creator>GeethaMN</dc:creator>
      <dc:date>2016-07-12T06:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to map to the previous variable value??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-map-to-the-previous-variable-value/m-p/283690#M57828</link>
      <description>&lt;P&gt;Use the lag function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;X_lag = lag(X);
Y=ifn(X=999, x_lag+0.1, X);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This doesn't deal with consecutive 999 so you'll need to figure out the logic for that. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2016 06:34:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-map-to-the-previous-variable-value/m-p/283690#M57828</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-12T06:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to map to the previous variable value??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-map-to-the-previous-variable-value/m-p/283692#M57830</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input X ;
cards; 
1      
2      
3   
4  
999  
1   
2  
3    
999 
999   
;
run;

data want;
 set have;
 retain Y;
 if X ne 999 then Y=X;
  else Y=Y+0.1;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jul 2016 06:49:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-map-to-the-previous-variable-value/m-p/283692#M57830</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-12T06:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to map to the previous variable value??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-map-to-the-previous-variable-value/m-p/283694#M57831</link>
      <description>&lt;P&gt;Or more simple :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set have;
 if X ne 999 then Y=X;
  else Y+0.1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jul 2016 06:54:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-map-to-the-previous-variable-value/m-p/283694#M57831</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-12T06:54:00Z</dc:date>
    </item>
  </channel>
</rss>

