<?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 derive lagged values (considering different time intervals )? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-lagged-values-considering-different-time-intervals/m-p/318588#M69819</link>
    <description>&lt;P&gt;You later asked about getting leads, for which there is no explicit SAS functions.&amp;nbsp; However, you can take advantage of the FIRSTOBS, KEEP, and RENAME parameters for data set names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The program below assumes your data are sorted by FIRMID/YEAR.&amp;nbsp; You want leads up to 6 years in advance, but there may be "holes" in the years subsequent to the current record (i.e. current year may be 1998, but it is followed by 2000,2001,2003,2004 - missing are 1999 and 2002):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;MERGE here purposely does NOT have a BY statement, and will not work correctly if it does.&lt;/LI&gt;
&lt;LI&gt;Each of the FIRSTOBS= datasets has an explicit list of KEEP variables and a corresponding RENAME list.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data want;
  merge have
        have (firstobs=2 keep=firmid year assets rename=(firmid=fid1 assets=ast1 year=yr1))
        have (firstobs=3 keep=firmid year assets rename=(firmid=fid2 assets=ast2 year=yr2))
        have (firstobs=4 keep=firmid year assets rename=(firmid=fid3 assets=ast3 year=yr3))
        have (firstobs=5 keep=firmid year assets rename=(firmid=fid4 assets=ast4 year=yr4))
        have (firstobs=6 keep=firmid year assets rename=(firmid=fid5 assets=ast5 year=yr5))
        have (firstobs=7 keep=firmid year assets rename=(firmid=fid6 assets=ast6 year=yr6))
        ;

  array ldassets {6};  /* lead values of assets, for year+1 through year+6 */

  array yr {6};
  array ast {6};
  array fid{6};

  do I=1 to 6 while (  fid{I}=firmid  and  (yr{I}-year)&amp;lt;= 6 );
    ldassets{yr{I}-year}=ast{I};
  end;
  drop I yr: ast: fid: ;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 13 Dec 2016 15:22:19 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2016-12-13T15:22:19Z</dc:date>
    <item>
      <title>How to derive lagged values (considering different time intervals )?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-lagged-values-considering-different-time-intervals/m-p/318392#M69757</link>
      <description>&lt;P&gt;&lt;FONT color="#000000" face="Courier New" size="2"&gt;Dear Sas Community,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Courier New" size="2"&gt;I am struggeling with a problem. I want to create lagged values of the variable asset. My dataset consists of observations of different firms and years (see example below).I use:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Have;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;Input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; FirmID year AssT;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;Datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;1 1990 100&lt;/P&gt;&lt;P&gt;1 1991 10&lt;/P&gt;&lt;P&gt;1 1994 3&lt;/P&gt;&lt;P&gt;1 1996 5&lt;/P&gt;&lt;P&gt;2 1990 100&lt;/P&gt;&lt;P&gt;2 1991 10&lt;/P&gt;&lt;P&gt;2 1992 3&lt;/P&gt;&lt;P&gt;2 1993 5&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Lagged1 (&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;drop&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=i count);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;Set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Have;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;By&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; firmID year;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; x(*) Assets1-Assets5;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Assets1=lag1 (AssT);&lt;/P&gt;&lt;P&gt;Assets2=lag2 (AssT);&lt;/P&gt;&lt;P&gt;Assets3=lag3 (AssT);&lt;/P&gt;&lt;P&gt;Assets4=lag4 (AssT);&lt;/P&gt;&lt;P&gt;Assets5=lag5 (AssT);&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; first.firmid &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; count=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=count &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; dim(x);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;x&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(i)=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;count + &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;The problem is that the time interval between the&amp;nbsp;observations of the same firm is not always exactly one year. So I get false lagged results.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Do you have an idea how to alter the code so that it also considers the different time intervals?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Many thanks in advance&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Best&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2016 22:03:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-derive-lagged-values-considering-different-time-intervals/m-p/318392#M69757</guid>
      <dc:creator>AnjaV</dc:creator>
      <dc:date>2016-12-12T22:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to derive lagged values (considering different time intervals )?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-lagged-values-considering-different-time-intervals/m-p/318398#M69760</link>
      <description>&lt;P&gt;You'll have to define that a little more.&amp;nbsp; "Considers the different time intervals"?&amp;nbsp; What would you like the results to be for your sample data?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2016 22:14:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-derive-lagged-values-considering-different-time-intervals/m-p/318398#M69760</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-12-12T22:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to derive lagged values (considering different time intervals )?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-lagged-values-considering-different-time-intervals/m-p/318410#M69764</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Hello astounding,&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;thanks for the quick reply. This is how I would like the results to be.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Have;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;Input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; FirmID year AssT Lag1Asst Lag2Asst Lag3Asst;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;Datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;1 1990 100 . . .&lt;/P&gt;&lt;P&gt;1 1991 10 100 . .&lt;/P&gt;&lt;P&gt;1 1994 3 . . 10&lt;/P&gt;&lt;P&gt;1 1996 5 . 3 . .&lt;/P&gt;&lt;P&gt;2 1990 100 . . .&lt;/P&gt;&lt;P&gt;2 1991 10 100 . .&lt;/P&gt;&lt;P&gt;2 1992 3 10 100 .&lt;/P&gt;&lt;P&gt;2 1993 5 3 10 100&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Best &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Anja&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2016 23:07:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-derive-lagged-values-considering-different-time-intervals/m-p/318410#M69764</guid>
      <dc:creator>AnjaV</dc:creator>
      <dc:date>2016-12-12T23:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to derive lagged values (considering different time intervals )?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-lagged-values-considering-different-time-intervals/m-p/318413#M69765</link>
      <description>&lt;P&gt;I suspect that you may need to create lags of the Firmid and then something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If firmid = LagFirmid1 then &amp;lt;do something&amp;gt; ;&lt;/P&gt;
&lt;P&gt;but it isn't quite clear.&lt;/P&gt;
&lt;P&gt;You may also want temporary variables to hold the lag of asst and conditionally assign x[i] to the temporary variable. The drop the LagFirm and the asset temporaries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you have a number of variables to set to missing you may want to consider call missing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Call missing (of x(*)); in the case of an entirer array or&lt;/P&gt;
&lt;P&gt;Call missing (x,y, z, p, d, q);&lt;/P&gt;
&lt;P&gt;Nice thing about call missing is you can mix variable types unlike most operations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I might guess you are attempting some like this:&lt;/P&gt;
&lt;PRE&gt;Data Lagged1 (drop=i );
   Set Have;
   By firmID year;
   array x(*) Assets1-Assets5;
   LAsst1=lag1 (AssT);
   LAsst2=lag2 (AssT);
   LAsst3=lag3 (AssT);
   LAsst4=lag4 (AssT);
   LAsst5=lag5 (AssT);
   LFirmId1=lag1 (FirmId);
   LFirmId2=lag2 (FirmId);
   LFirmId3=lag3 (FirmId);
   LFirmId4=lag4 (FirmId);
   LFirmId5=lag5 (FirmId);
   array LA Lasst1-LAsst5;
   array f LFirmId1-LFirmId5;
   call missing (of x(*));
   do i=1 to dim(x);
      if f[i]=firmid then x[i]= LA[i];
   end;
   drop Lf: LA:;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Dec 2016 23:16:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-derive-lagged-values-considering-different-time-intervals/m-p/318413#M69765</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-12-12T23:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to derive lagged values (considering different time intervals )?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-lagged-values-considering-different-time-intervals/m-p/318435#M69766</link>
      <description>&lt;P&gt;It looks like there should be an easy way, but I only see a method with a lot of details. &amp;nbsp;So here goes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by firmid&amp;nbsp;year;&lt;/P&gt;
&lt;P&gt;array firms {5} $;&lt;/P&gt;
&lt;P&gt;array assets {5};&lt;/P&gt;
&lt;P&gt;array yrdifs {5};&lt;/P&gt;
&lt;P&gt;array amounts {5} lag1Asst lag2Asst lag3Asswt lag4Asst lag5Asst;&lt;/P&gt;
&lt;P&gt;firms1 = lag1(firm); firms2 = lag2(firm); firms3 = lag3(firm); firms4 = lag4(firms); firms5 = lag5(firms);&lt;/P&gt;
&lt;P&gt;assets1 = lag1(AssT); assets2 = lag2(AssT); assets3 = lag3(AssT); assets4 = lag4(AssT); assets5 = lag5(AssT);&lt;/P&gt;
&lt;P&gt;yrdifs1 = dif1(year); yrdifs2 = dif2(year); yrdifs3 = dif3(year); yrdifs4 = dif4(year); yrdifs5 = dif5(year);&lt;/P&gt;
&lt;P&gt;do _n_=1 to 5;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if firms{_n_} = firm then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (1 &amp;lt;= yrdifs{_n_} &amp;lt;= 5) then amounts{yrdifs{_n_}} = assets{_n_};&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop firm1-firm5 assets1-assets5 yrdifs1-yrdifs5;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's untested, and I wish I could think of something simpler. &amp;nbsp;But at least it ought to work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2016 03:19:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-derive-lagged-values-considering-different-time-intervals/m-p/318435#M69766</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-12-13T03:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to derive lagged values (considering different time intervals )?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-lagged-values-considering-different-time-intervals/m-p/318531#M69804</link>
      <description>&lt;P&gt;Great, thank you very much. Works perfectly!!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to modify your code so that it produces look-ahead values instead of lagged values?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2016 11:58:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-derive-lagged-values-considering-different-time-intervals/m-p/318531#M69804</guid>
      <dc:creator>AnjaV</dc:creator>
      <dc:date>2016-12-13T11:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to derive lagged values (considering different time intervals )?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-lagged-values-considering-different-time-intervals/m-p/318555#M69808</link>
      <description>&lt;P&gt;Not really.&amp;nbsp; SAS has decent tools for looking backward and a much more limited set of tools for looking forward through the data.&amp;nbsp; It is posible to program that, but the program wouldn't resemble this program.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2016 13:22:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-derive-lagged-values-considering-different-time-intervals/m-p/318555#M69808</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-12-13T13:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to derive lagged values (considering different time intervals )?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-lagged-values-considering-different-time-intervals/m-p/318588#M69819</link>
      <description>&lt;P&gt;You later asked about getting leads, for which there is no explicit SAS functions.&amp;nbsp; However, you can take advantage of the FIRSTOBS, KEEP, and RENAME parameters for data set names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The program below assumes your data are sorted by FIRMID/YEAR.&amp;nbsp; You want leads up to 6 years in advance, but there may be "holes" in the years subsequent to the current record (i.e. current year may be 1998, but it is followed by 2000,2001,2003,2004 - missing are 1999 and 2002):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;MERGE here purposely does NOT have a BY statement, and will not work correctly if it does.&lt;/LI&gt;
&lt;LI&gt;Each of the FIRSTOBS= datasets has an explicit list of KEEP variables and a corresponding RENAME list.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data want;
  merge have
        have (firstobs=2 keep=firmid year assets rename=(firmid=fid1 assets=ast1 year=yr1))
        have (firstobs=3 keep=firmid year assets rename=(firmid=fid2 assets=ast2 year=yr2))
        have (firstobs=4 keep=firmid year assets rename=(firmid=fid3 assets=ast3 year=yr3))
        have (firstobs=5 keep=firmid year assets rename=(firmid=fid4 assets=ast4 year=yr4))
        have (firstobs=6 keep=firmid year assets rename=(firmid=fid5 assets=ast5 year=yr5))
        have (firstobs=7 keep=firmid year assets rename=(firmid=fid6 assets=ast6 year=yr6))
        ;

  array ldassets {6};  /* lead values of assets, for year+1 through year+6 */

  array yr {6};
  array ast {6};
  array fid{6};

  do I=1 to 6 while (  fid{I}=firmid  and  (yr{I}-year)&amp;lt;= 6 );
    ldassets{yr{I}-year}=ast{I};
  end;
  drop I yr: ast: fid: ;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Dec 2016 15:22:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-derive-lagged-values-considering-different-time-intervals/m-p/318588#M69819</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-12-13T15:22:19Z</dc:date>
    </item>
  </channel>
</rss>

