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 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 17 May 2008 17:29:42 -0700
Reply-To:     "dc353@hotmail.com" <dc353@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "dc353@hotmail.com" <dc353@HOTMAIL.COM>
Organization: http://groups.google.com
Subject:      generate dates
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset=ISO-8859-1

Hi,

I'm trying to generate yyyymm dates in a do loop. The following code works but doesn't rely on SAS dates. Is there an easier way using SAS dates??

DATA _NULL_; startdate = 200301; enddate = 200704;

yr = int(enddate/100) - int(startdate/100); mt = (enddate - int(enddate/100)*100) - (startdate - int(startdate/ 100)*100); if mt < 0 then do; yr = yr - 1; mt = mt + 12; end;

cnt = yr*12 + mt; syr = int(startdate/100); smt = startdate - syr*100;

do i = 0 to cnt; yr_inc = int((smt+i)/12); mt_inc = mod(smt+i,12); if mt_inc = 0 then mt_inc=12;

newdate= (syr+yr_inc)*100 + mt_inc; put newdate; end;

run;

What would be nice is something like:

do i = startdate to enddate (increment month by 1); end;


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