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-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
  • 8 replies
  • 1032 views
  • 1 like
  • 4 in conversation