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
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
>
>
|