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 (May 2005, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 12 May 2005 11:27:24 -0400
Reply-To:     "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject:      Re: SAS Programming With Dates -Problem

Still no explanation of the second field. However, it turns out that its values are unformatted SAS dates falling in the indicated months. In other words, we don't need the explicit month field, because it can be derived.

Here's one way to solve the problem. First load the test data:

data have; input id1 date month $ id2 x y; cards; 31806 15538 2002JUL 1339 303 0 [snip] 33870 15166 2001JUL 1254 20 20 ;

Now replace the character variable MONTH with a numeric one:

data fixed; set have(drop = month); month = intnx('month',date,0); format date date9. month monyy7.; run;

Next, generate a data set spanning all required months for each ID pair:

data all; set fixed (keep = id1 id2 month); retain x y 0; by id1 id2; if first.id2; do until (month > '01apr2005'd); output; month = intnx('month',month,1); end; run;

Note that X and Y are zero-valued throughout. Finally, drop in the known values:

data wouldlike; update all fixed; by id1 id2 month; run;

On Wed, 11 May 2005 13:04:20 -0500, dmka <djrk0003@COMCAST.NET> wrote:

>For the new months created, the last two variables below should take a value >of Zero. The Third variable should maintain their values for each accountid. > >Thanks, >----- Original Message ----- >From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM> >To: <SAS-L@LISTSERV.UGA.EDU> >Sent: Tuesday, May 10, 2005 9:57 PM >Subject: Re: SAS Programming With Dates -Problem > > >> You have four variables in addition to the ID and the date. What values >> should they assume in the new observations? >> >> On Mon, 9 May 2005 20:30:43 +0000, Doyle Kalumbi <djrk0003@COMCAST.NET> >> wrote: >> >> >Hi Users: >> > >> >I have a data set with date fields that are not evenly spaces by month. I >> would like to create a field with evenly spaced months from the first date >> value up to '30Apr2005'. For example the first observation with >> Accountid=31806 and a Trans_TransactionDateMoa value of 2002Jul: I would >> like to create the following date values inserted in between: >> >2002Jul >> >2002Aug >> >2002Sep >> >2002Oct >> >" >> >" >> >2005Apr >> > >> >For Accountid 31992, I would like to even dates starting from 2001Nov to >> 2005Apr including the 2002Feb. Below is a sample of my data structure: >> > >> >Thanks, >> > >> >Doyle, >> > >> > >> >31806 15538 2002JUL 1339 303 0 >> >31822 15348 2002JAN 4048 50 50 >> >31992 15295 2001NOV 1202 275 275 >> >31992 15381 2002FEB 1202 -275 -275 >> >32294 15382 2002FEB 2377 951 951 >> >32318 15237 2001SEP 3034 62 247 >> >32360 16022 2003NOV 7071 38 38 >> >32559 16187 2004APR 4773 319 319 >> >32559 16280 2004JUL 4773 210 420 >> >32559 16303 2004AUG 4773 210 210 >> >32559 16331 2004SEP 4773 210 210 >> >32559 16369 2004OCT 4773 211 211 >> >32559 16397 2004NOV 4773 210 210 >> >32559 16427 2004DEC 4773 211 211 >> >32559 16464 2005JAN 4773 421 421 >> >32559 16516 2005MAR 4773 210 210 >> >32559 16553 2005APR 4773 210 210 >> >33269 15260 2001OCT 5869 2867 2867 >> >33615 15144 2001JUN 3427 839 839 >> >33615 15265 2001OCT 3427 91 167 >> >33615 15305 2001NOV 3427 90 90 >> >33615 15326 2001DEC 3427 91 91 >> >33615 15363 2002JAN 3427 34 119 >> >33615 15390 2002FEB 3427 148 148 >> >33615 15455 2002APR 3427 79 170 >> >33615 15490 2002MAY 3427 85 85 >> >33615 15544 2002JUL 3427 98 189 >> >33615 15600 2002SEP 3427 91 91 >> >33615 15635 2002OCT 3427 98 98 >> >33748 15180 2001JUL 2675 56 56 >> >33810 15533 2002JUL 1911 22 22 >> >33810 15564 2002AUG 1911 51 51 >> >33810 15594 2002SEP 1911 144 144 >> >33810 15628 2002OCT 1911 51 51 >> >33810 15656 2002NOV 1911 51 51 >> >33810 15719 2003JAN 1911 148 148 >> >33810 15746 2003FEB 1911 51 51 >> >33810 15774 2003MAR 1911 51 51 >> >33810 15809 2003APR 1911 51 51 >> >33810 15837 2003MAY 1911 51 51 >> >33810 15902 2003JUL 1911 57 57 >> >33810 15929 2003AUG 1911 146 146 >> >33810 15960 2003SEP 1911 52 52 >> >33810 15992 2003OCT 1911 51 51 >> >33810 16051 2003DEC 1911 55 55 >> >33810 16082 2004JAN 1911 144 144 >> >33810 16113 2004FEB 1911 54 54 >> >33810 16145 2004MAR 1911 93 93 >> >33810 16173 2004APR 1911 14 14 >> >33870 15166 2001JUL 1254 20 20


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