<?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 Generating Multiple Lags? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Generating-Multiple-Lags/m-p/46986#M12559</link>
    <description>Hi:&lt;BR /&gt;
I want to generate multiple lags(4000+)  for many variables ( a, b, c). how is it possible w/o writing thousands of statements:&lt;BR /&gt;
&lt;BR /&gt;
lag_a_1 = lag1(a);&lt;BR /&gt;
lag_a_2 = lag2(a);&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
lag_a_4000= lag4000(a);  . . . and so on for other variables.&lt;BR /&gt;
&lt;BR /&gt;
I tried using Array function in the following but it doesnt work:&lt;BR /&gt;
&lt;BR /&gt;
DATA xxx.yyy (drop = i);&lt;BR /&gt;
     SET xxx.yyy;&lt;BR /&gt;
&lt;BR /&gt;
ARRAY Lag_a_{4000};&lt;BR /&gt;
do i= 1 to 4000;&lt;BR /&gt;
Lag_a_(i)= lag(i)(a);&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
any help?&lt;BR /&gt;
Regards&lt;BR /&gt;
Moazzam</description>
    <pubDate>Fri, 19 Jun 2009 20:18:05 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-06-19T20:18:05Z</dc:date>
    <item>
      <title>Generating Multiple Lags?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generating-Multiple-Lags/m-p/46986#M12559</link>
      <description>Hi:&lt;BR /&gt;
I want to generate multiple lags(4000+)  for many variables ( a, b, c). how is it possible w/o writing thousands of statements:&lt;BR /&gt;
&lt;BR /&gt;
lag_a_1 = lag1(a);&lt;BR /&gt;
lag_a_2 = lag2(a);&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
lag_a_4000= lag4000(a);  . . . and so on for other variables.&lt;BR /&gt;
&lt;BR /&gt;
I tried using Array function in the following but it doesnt work:&lt;BR /&gt;
&lt;BR /&gt;
DATA xxx.yyy (drop = i);&lt;BR /&gt;
     SET xxx.yyy;&lt;BR /&gt;
&lt;BR /&gt;
ARRAY Lag_a_{4000};&lt;BR /&gt;
do i= 1 to 4000;&lt;BR /&gt;
Lag_a_(i)= lag(i)(a);&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
any help?&lt;BR /&gt;
Regards&lt;BR /&gt;
Moazzam</description>
      <pubDate>Fri, 19 Jun 2009 20:18:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generating-Multiple-Lags/m-p/46986#M12559</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-06-19T20:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Multiple Lags?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generating-Multiple-Lags/m-p/46987#M12560</link>
      <description>Try this...&lt;BR /&gt;
&lt;BR /&gt;
%macro check;&lt;BR /&gt;
data X;&lt;BR /&gt;
  set Y;&lt;BR /&gt;
%do i = 1 %to 4000;&lt;BR /&gt;
    lag_a_&amp;amp;i = lag&amp;amp;i(a);&lt;BR /&gt;
%end;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend check;&lt;BR /&gt;
&lt;BR /&gt;
%check;</description>
      <pubDate>Fri, 19 Jun 2009 20:59:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generating-Multiple-Lags/m-p/46987#M12560</guid>
      <dc:creator>NickR</dc:creator>
      <dc:date>2009-06-19T20:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Multiple Lags?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generating-Multiple-Lags/m-p/46988#M12561</link>
      <description>It may be useful to explain your interest with sample INPUT and OUTPUT (desired) data example, in case there may be an alternative approach?&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 19 Jun 2009 22:06:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generating-Multiple-Lags/m-p/46988#M12561</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-19T22:06:07Z</dc:date>
    </item>
  </channel>
</rss>

