<?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: Lags and Lead in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Lags-and-Lead/m-p/879582#M347490</link>
    <description>Thank you so much!</description>
    <pubDate>Wed, 07 Jun 2023 15:00:16 GMT</pubDate>
    <dc:creator>yp2609</dc:creator>
    <dc:date>2023-06-07T15:00:16Z</dc:date>
    <item>
      <title>Lags and Lead</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lags-and-Lead/m-p/879559#M347482</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yp2609_0-1686147884665.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84775iA3A7004D9ABC0077/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yp2609_0-1686147884665.png" alt="yp2609_0-1686147884665.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I want to divide 2nd row of j_top by the 1st row of j_denom; divide 3rd row of j_top by 2nd rows of j_denom; so on and so forth.&amp;nbsp;&lt;/P&gt;&lt;P&gt;lag function is not working as I want it to be.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone provide code for this? Thank you so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2023 14:26:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lags-and-Lead/m-p/879559#M347482</guid>
      <dc:creator>yp2609</dc:creator>
      <dc:date>2023-06-07T14:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Lags and Lead</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lags-and-Lead/m-p/879569#M347483</link>
      <description>&lt;P&gt;Show us your code. Show us the log. Explain what is wrong.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2023 14:33:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lags-and-Lead/m-p/879569#M347483</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-07T14:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: Lags and Lead</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lags-and-Lead/m-p/879572#M347485</link>
      <description>&lt;P&gt;Nothing is wrong. I just have no clue how to perform this code.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2023 14:36:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lags-and-Lead/m-p/879572#M347485</guid>
      <dc:creator>yp2609</dc:creator>
      <dc:date>2023-06-07T14:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: Lags and Lead</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lags-and-Lead/m-p/879575#M347486</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440996"&gt;@yp2609&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to divide 2nd row of j_top by the 1st row of j_denom; divide 3rd row of j_top by 2nd rows of j_denom; so on and so forth.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;lag function is not working as I want it to be.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone provide code for this? Thank you so much!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;When you say code isn't working you should show the code and possibly the LOG if you are getting unexpected notes in the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because Lag, and its partner Dif, function is a queue function then using it conditionally is the main cause of unexpected results as the "lag" then becomes the last time the condition was true.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2023 14:37:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lags-and-Lead/m-p/879575#M347486</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-06-07T14:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: Lags and Lead</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lags-and-Lead/m-p/879576#M347487</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt; divide 2nd row of j_top by the 1st row of j_denom;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  lag_j_denom=lag(j_denom);
  if _n_ =1 then want = j_top;
 else want=j_top/lag_j_denom;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2023 14:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lags-and-Lead/m-p/879576#M347487</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-07T14:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Lags and Lead</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lags-and-Lead/m-p/879582#M347490</link>
      <description>Thank you so much!</description>
      <pubDate>Wed, 07 Jun 2023 15:00:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lags-and-Lead/m-p/879582#M347490</guid>
      <dc:creator>yp2609</dc:creator>
      <dc:date>2023-06-07T15:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: Lags and Lead</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lags-and-Lead/m-p/879586#M347493</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440996"&gt;@yp2609&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your topic title (title of your post) is misleading.&lt;/P&gt;
&lt;P&gt;But if you don't know how a data step works, I agree you have difficulties in knowing whether you need lag or lead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope it's clear by now you only need lag.&lt;/P&gt;
&lt;P&gt;When processing observation &lt;EM&gt;k&lt;/EM&gt; you need info that is from observation &lt;EM&gt;(k-1)&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;That's looking back.&lt;/P&gt;
&lt;P&gt;Looking ahead is not needed here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2023 15:10:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lags-and-Lead/m-p/879586#M347493</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-06-07T15:10:28Z</dc:date>
    </item>
  </channel>
</rss>

