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

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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