<?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 use lag function recursively in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-lag-function-recursively/m-p/171029#M44182</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The lag function in SAS is a queue functionality and is quite different then the lag en lead functions in Oracle / MS-Sql&lt;/P&gt;&lt;P&gt;For not getting confused avoid using that same name for that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you are possible trying to do is known as "impute missings"&amp;nbsp; as that is part of the mining steps.&lt;/P&gt;&lt;P&gt;Just putting in the previous value is not the best strategy to do that, there are several more approaches . &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Nov 2014 06:55:23 GMT</pubDate>
    <dc:creator>jakarman</dc:creator>
    <dc:date>2014-11-14T06:55:23Z</dc:date>
    <item>
      <title>How to use lag function recursively</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-lag-function-recursively/m-p/171026#M44179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a huge data with a lot of missing values for a variable.&amp;nbsp; For example, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data a;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input x y;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;1 1&lt;/P&gt;&lt;P&gt;1 0&lt;/P&gt;&lt;P&gt;1 .&lt;/P&gt;&lt;P&gt;1 .&lt;/P&gt;&lt;P&gt;2 2&lt;/P&gt;&lt;P&gt;2 3&lt;/P&gt;&lt;P&gt;2 9&lt;/P&gt;&lt;P&gt;2 .&lt;/P&gt;&lt;P&gt;2 .&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I want to fill in the missing y with its lagged value. That is, for x=1, y=0 for the missing ones and x=2, y=9 for the last two observations. But when I use lag function, it only fills in the first missing observation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone please tell me how to do this? Please note, the data is large. So it's better to avoid open/close data too many times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sunny&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Nov 2014 00:35:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-lag-function-recursively/m-p/171026#M44179</guid>
      <dc:creator>Sunny_Sun</dc:creator>
      <dc:date>2014-11-14T00:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to use lag function recursively</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-lag-function-recursively/m-p/171027#M44180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is probably simpler than you thought with UPDATE processing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data want;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;update a(obs=0) a;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;by x;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;output;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Nov 2014 01:14:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-lag-function-recursively/m-p/171027#M44180</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-11-14T01:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to use lag function recursively</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-lag-function-recursively/m-p/171028#M44181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data want(drop=y rename=(y1=y));&lt;/P&gt;&lt;P&gt;set a;&lt;/P&gt;&lt;P&gt;retain y1;&lt;/P&gt;&lt;P&gt;if y&amp;gt;. then y1=y;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Nov 2014 03:50:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-lag-function-recursively/m-p/171028#M44181</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-11-14T03:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to use lag function recursively</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-lag-function-recursively/m-p/171029#M44182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The lag function in SAS is a queue functionality and is quite different then the lag en lead functions in Oracle / MS-Sql&lt;/P&gt;&lt;P&gt;For not getting confused avoid using that same name for that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you are possible trying to do is known as "impute missings"&amp;nbsp; as that is part of the mining steps.&lt;/P&gt;&lt;P&gt;Just putting in the previous value is not the best strategy to do that, there are several more approaches . &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Nov 2014 06:55:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-lag-function-recursively/m-p/171029#M44182</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-11-14T06:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to use lag function recursively</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-lag-function-recursively/m-p/171030#M44183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many thanks all of you! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sunny&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Nov 2014 16:15:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-lag-function-recursively/m-p/171030#M44183</guid>
      <dc:creator>Sunny_Sun</dc:creator>
      <dc:date>2014-11-14T16:15:56Z</dc:date>
    </item>
  </channel>
</rss>

