Date: Wed, 7 Oct 2009 08:54:54 -0500
Reply-To: Joe Matise <snoopy369@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Joe Matise <snoopy369@GMAIL.COM>
Subject: Re: Convert month variable from character to numeric using 9.1
Content-Type: text/plain; charset=ISO-8859-1
The MONYY. informat should read it in, if you append a year to it (either 2
or 4 digit).
newvar = input(cats(monvar,'09'),MONYY5.);
should do it. This assumes that it's stored as a character variable (format
$3. or similar). Of course it gives it a 2009 year, you may choose a
different one as your needs require [but you DO need to choose one].
input monvar $;
format numvar MONYY5.;
numvar = input(cats(monvar,'09'),MONYY5.);
proc print; run;
On Tue, Oct 6, 2009 at 7:09 PM, JC <email@example.com> wrote:
> i have a dataset with month stored as a separate variable as mmm.
> I need to convert this to a numeric field so that i can use the mdy
> Can someone please help me convert the month field to numeric.
> I have tried the input function and it leaves my new variable blank.
> Thank you!