BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi:
I want to generate multiple lags(4000+) for many variables ( a, b, c). how is it possible w/o writing thousands of statements:

lag_a_1 = lag1(a);
lag_a_2 = lag2(a);
.
.
.
lag_a_4000= lag4000(a); . . . and so on for other variables.

I tried using Array function in the following but it doesnt work:

DATA xxx.yyy (drop = i);
SET xxx.yyy;

ARRAY Lag_a_{4000};
do i= 1 to 4000;
Lag_a_(i)= lag(i)(a);
end;
run;
any help?
Regards
Moazzam
2 REPLIES 2
NickR
Quartz | Level 8
Try this...

%macro check;
data X;
set Y;
%do i = 1 %to 4000;
lag_a_&i = lag&i(a);
%end;
run;
%mend check;

%check;
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
It may be useful to explain your interest with sample INPUT and OUTPUT (desired) data example, in case there may be an alternative approach?

Scott Barry
SBBWorks, Inc.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 566 views
  • 0 likes
  • 3 in conversation