BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sasphd
Lapis Lazuli | Level 10

can someone tell me how to write lagged variable in proc panel

 

I write

y= lag(X);

it does not work???????????

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

lag is not an option but, rather, a statement. e.g.,

LAG var( ... ) , ..., var( ... ) < / OUT= SAS-data-set > ;

You use it to create an output dataset that would then be analyzed with a separate call to proc panek,

 

Art, CEO, AnalystFinder.com

 

View solution in original post

8 REPLIES 8
art297
Opal | Level 21
lag X1(1 3) X2(3 6 9) X3(2) / out=A_lag;

It's defined at: http://support.sas.com/documentation/cdl/en/etsug/63939/HTML/default/viewer.htm#etsug_panel_sect015....

 

Art, CEO, AnalystFinder.com

 

sasphd
Lapis Lazuli | Level 10

I see that 

What does it mean 

(1 3)
(3 6 9)

 

(2)
art297
Opal | Level 21

if you only want a lag of 1 for variable X you would use: lag x(1);

 

Art, CEO, AnalystFinder.com

 

Reeza
Super User

RTM - the link was provided.

 

LAG var( ... ) , ..., var( ... ) < / OUT= SAS-data-set > ;

 

So the VAR indicates the variable that a lag will be created for, while the numbers in the parentheses indicate the lag that will be calculated ie

 

lag var1 (1 2 3) creates 3 lagged variables for a lag of 1, 2 and 3 periods respectively. 

 

RTM to see how the variables are labeled or alternatives to the LAG function.

sasphd
Lapis Lazuli | Level 10

I write my program like that but it does not work

 

proc panel data= flux;
id rankdate rank_no;
model flux= lag estimate(1) / fixone noint HCCME=0 cluster;
ods output ParameterEstimates=res;
run;

art297
Opal | Level 21

lag is not an option but, rather, a statement. e.g.,

LAG var( ... ) , ..., var( ... ) < / OUT= SAS-data-set > ;

You use it to create an output dataset that would then be analyzed with a separate call to proc panek,

 

Art, CEO, AnalystFinder.com

 

sasphd
Lapis Lazuli | Level 10

can you please write for me an example of the statement 

Rick_SAS
SAS Super FREQ
??? The blue text in art297's original reply is called a hyperlink. If you click on it, your browser will display the documentation, which contains the example that you are asking for.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 1565 views
  • 1 like
  • 4 in conversation