LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (March 2003, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 31 Mar 2003 10:24:55 -0500
Reply-To:     diskin.dennis@KENDLE.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         diskin.dennis@KENDLE.COM
Subject:      Re: repeated code
Comments: To: Jean Roth <jroth@NBER.ORG>
Content-type: text/plain; charset=us-ascii

Jean,

Yes, easily:

%macro lags(n=1,var=,out=); %local i; %do i = 1 %to &n; &out.&i = lag%eval(&i-1)(&var); %end; %mend;

data one; set one; %lags(n=72,var=stdsvc,out=svctyp) .... run;

HTH, Dennid Diskin

From: Jean Roth <jroth@NBER.ORG>@LISTSERV.UGA.EDU> on 03/31/2003 09:44 AM

Please respond to Jean Roth <jroth@NBER.ORG>

Sent by: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>

To: SAS-L@LISTSERV.UGA.EDU cc:

Subject: repeated code

Hi Macro Mavens,

I'd like to create a bunch of lag variables for a dataset

data one; set one; svctyp1 = stdsvc; svctyp2 = lag1(stdsvc); ... svctyp72 = lag71(stdsvc);

Can I do this without a line of code for each lag variable?

Thanks,

Jean Roth National Bureau of Economic Research http://www.nber.org/data


Back to: Top of message | Previous page | Main SAS-L page