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 1999, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 20 May 1999 13:20:32 -0700
Reply-To:     "Berryhill, Timothy" <TWB2@PGE.COM>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         "Berryhill, Timothy" <TWB2@PGE.COM>
Subject:      Re: year/month calculation
Comments: To: Andy Yuan <YuanA@DIME.COM>
Content-Type: text/plain

Usually, I pick out the year and month and assume a day of 1 so that I can create a SAS date value. Then the INTCK function will return the duration:

DATA DURATION(KEEP=START END WANT); SDATE=MDY(SUBSTR(START,3),1,SUBSTR(START,1,2)); EDATE=MDY(SUBSTR(END,3),1,SUBSTR(END,1,2)); WANT=INTCK('MONTH',SDATE,EDATE); RUN;

The MDY function expects numeric inputs and this provides character values for month and year, but I rarely bother to use the INPUT function to convert the characters into numerics.

Tim Berryhill - Contract Programmer and General Wizard TWB2@PGE.COM or http://www.aartwolf.com/twb.html Frequently at Pacific Gas & Electric Co., San Francisco The correlation coefficient between their views and my postings is slightly less than 0

> ---------- > From: Andy Yuan[SMTP:YuanA@DIME.COM] > Reply To: Andy Yuan > Sent: Thursday, May 20, 1999 12:59 PM > To: SAS-L@UGA.CC.UGA.EDU > Subject: year/month calculation > > Hi, SAS_Lers > > I have two variables with yymm format. How to do calculation directly to > get the duration in months. > e.g. > > start end want _ > 9612 9710 10 > 9503 9905 51 > ... > > Thanks > >


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