Date: Sun, 11 May 2003 01:24:49 +1000
Reply-To: reply@sasl.no.spam
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: ListServer <reply@SASL.NO.SPAM>
Subject: Re: extracting 1 or 2 digit month from date - simple/newbie I'm
sure
In-Reply-To: <20030509190042.E4FCB15BD25@mail10.easyspace.com>
Content-Type: text/plain; charset="iso-8859-1"
Jason,
the simplest way to deal with this is to first use a process that should be
one of your more common techniques: convert the date into a number, so that
SAS can handle it with its native processes.
Then extract the month with another standard SAS function.
Substringing dates is as sharp as the intellect of Corporal Agarn, and not
suited to shaving anything!!!
Here is some code.
100 Data DATES;
101 Length USDATE $8.;
102 USDATE = '4/11/03';
103 DTMONTH = Month( Input( USDATE, Mmddyy8.) );
104 Put USDATE = DTMONTH=;
105 USDATE = '12/25/02';
106 DTMONTH = Month( Input( USDATE, Mmddyy8.) );
107 Put USDATE = DTMONTH=;
108 Run ;
USDATE=4/11/03 DTMONTH=4
USDATE=12/25/02 DTMONTH=12
NOTE: The data set WORK.DATES has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.03 seconds
Kind regards
David Johnson
sas_l@dkSASvj.bSASiz
> From: jason@CYBERPINE.COM [mailto:jason@CYBERPINE.COM]
> Subject: Re: extracting 1 or 2 digit month from date - simple/newbie I'm s
ure
>i've got a field with :
>
> mm/dd/yy or m/d/yy depending 1 digit or 2 digit days/months.
>
> I need sas code to pull out month (be it 1 or 2 digits).
>
> How can i do this? I was looking at substr and rxparse - but
> not seeing it.