Date: Thu, 5 Jun 2008 14:00:17 -0700
Reply-To: "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Subject: Re: Convert the month to a proper numeric format so that MDY
function works properly
In-Reply-To: A<c2192a610806051343k3ae4fed0ib9635618bfb65635@mail.gmail.com>
Content-Type: text/plain; charset="us-ascii"
Hi,
Remove the dollarsigns from the formats
in the INPUT() functions. The INPUT()
function is converting string to numeric
so the format given is what the outgoing
is to be converted to, and since we are
doing string to numeric, then the format
should be numeric. e.g.
data aa;
date = '01' ; month = 'JAN'; YEAR= '1998'; OUTPUT ;
date = '02' ; month = 'FEB'; YEAR= '1998'; OUTPUT ;
date = '03' ; month = 'MAR'; YEAR= '1998'; OUTPUT ;
date = '04' ; month = 'APR'; YEAR= '1998'; OUTPUT ;
Run;
data aa;
set aa;
Num_date=mdy(month(INPUT(month!!'01',monyy5.)),
INPUT(date,3.),
INPUT(year,4.)
);
format Num_date date9.;
Run;
INPUT() -- string to numeric convertion
PUT() -- numeric to string conversion
Hope this is helpful.
Mark Terjeson
Senior Programmer Analyst
Investment Management & Research
Russell Investments
Russell Investments
Global Leaders in Multi-Manager Investing
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
SAS_learner
Sent: Thursday, June 05, 2008 1:44 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Convert the month to a proper numeric format so that MDY
function works properly
hello guys I am using following technique but SAS Program is complaining
in
the Log about the Character to Numeric conversion, Instead of this I can
write a bunch of if /then else statements which I do not want.Is there a
better way if doing it without the Log Complaint
data aa;
date = '01' ; month = 'JAN'; YEAR= '1998'; OUTPUT ;
date = '02' ; month = 'FEB'; YEAR= '1998'; OUTPUT ;
date = '03' ; month = 'MAR'; YEAR= '1998'; OUTPUT ;
date = '04' ; month = 'APR'; YEAR= '1998'; OUTPUT ;
Run;
data aa;
set aa;
Num_date
=mdy(month(INPUT(month!!'01',monyy5.)),INPUT(date,$3.),INPUT(year,$4.));
Run;
NOTE: Character values have been converted to numeric
values at the places given by: (Line):(Column).
6842:49 6842:65
NOTE: There were 4 observations read from the data set WORK.AA.
NOTE: The data set WORK.AA has 4 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds