Help using Base SAS procedures

lag statement

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 118
Accepted Solution

lag statement

[ Edited ]

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

 

I write

y= lag(X);

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


Accepted Solutions
Solution
‎04-19-2017 09:46 AM
PROC Star
Posts: 7,363

Re: lag statement

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


All Replies
PROC Star
Posts: 7,363

Re: lag statement

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

 

Frequent Contributor
Posts: 118

Re: lag statement

I see that 

What does it mean 

(1 3)
(3 6 9)

 

(2)
PROC Star
Posts: 7,363

Re: lag statement

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

 

Art, CEO, AnalystFinder.com

 

Super User
Posts: 17,840

Re: lag statement

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.

Frequent Contributor
Posts: 118

Re: lag statement

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;

Solution
‎04-19-2017 09:46 AM
PROC Star
Posts: 7,363

Re: lag statement

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

 

Frequent Contributor
Posts: 118

Re: lag statement

can you please write for me an example of the statement 

SAS Super FREQ
Posts: 3,481

Re: lag statement

??? 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.
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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