Date: Fri, 23 Oct 2009 16:40:03 -0400
Reply-To: Norm Weston <nweston@AMGEN.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Norm Weston <nweston@AMGEN.COM>
Subject: Re: converting text to date to quarter
There is probably a more elegent way of doing it, but this should get you
there:
DATA HAVE;
INPUT date $17.;
CARDS;
January 2008
February 2008
;
RUN;
DATA WANT;
SET HAVE;
FORMAT QUARTER YYQ6. ;
DATE=UPCASE(DATE);
XVAL = SUBSTR(DATE,1,3)||COMPRESS(DATE,COMPRESS(DATE,'1234567890'));
QUARTER = INPUT(XVAL,MONYY7.);
DROP XVAL;
RUN;
|