LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2012, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 5 Apr 2012 14:27:20 +0000
Reply-To:     "Keintz, H. Mark" <mkeintz@WHARTON.UPENN.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Keintz, H. Mark" <mkeintz@WHARTON.UPENN.EDU>
Subject:      Re: Inserting blank rows
Comments: To: Randy <randistan69@HOTMAIL.COM>
In-Reply-To:  <201204051001.q354TDA9013265@waikiki.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"

Randy:

If your goal is to faciliate a regression using lagged variables within groups of records (i.e. each DATE/IDA combination is a group), then there is a better solution than putting in three completely blank records between groups (I presume this means that you expect to use a 3-record lag somewhere).

Consider just setting the value of lagged fields to missing as appropriate when beginning a new group, as in:

data want (drop=_: ); retain _n 0; set have; by date ida; if first.ida then _N=1; else _n+1;

L3=lag3(vara); L2=lag2(vara); L1=lag1(vara); array L {3} L1-L3;

if _N<=3 then do _I= 1 to 4 - _n; L{_I}=.; end; run;

proc reg data=want; by date ida; model ..... ; quit;

regards, Mark

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Randy Sent: Thursday, April 05, 2012 6:02 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Inserting blank rows

Dear All: I want to insert blank rows at fixed points in the dataset. The reason is that I want to run regressions using lagged variables and I do not want an overlap.

My Dataset is as follows:

Date IDA IDB VarA 01MAR2012 1 1 4 01MAR2012 1 2 6 01MAR2012 1 3 3 01MAR2012 1 4 8 01MAR2012 1 5 2 02MAR2012 1 1 10 02MAR2012 1 2 14 02MAR2012 1 3 18 02MAR2012 1 4 4 01MAR2012 2 1 7 01MAR2012 2 2 3 01MAR2012 2 3 22 01MAR2012 2 4 14 01MAR2012 2 5 1

I want the data set to look as follows. I want to insert three rows after each Date and IDA

Date IDA IDB VarA 01MAR2012 1 1 4 01MAR2012 1 2 6 01MAR2012 1 3 3 01MAR2012 1 4 8 01MAR2012 1 5 2

02MAR2012 1 1 10 02MAR2012 1 2 14 02MAR2012 1 3 18 02MAR2012 1 4 4

01MAR2012 2 1 7 01MAR2012 2 2 3 01MAR2012 2 3 22 01MAR2012 2 4 14 01MAR2012 2 5 1

Randy


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