LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments: To: JC <>
In-Reply-To:  <>
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].


data test; input monvar $; datalines; JAN FEB MAR DEC ;;;; run;

data want; set test; format numvar MONYY5.; numvar = input(cats(monvar,'09'),MONYY5.); run; proc print; run;


On Tue, Oct 6, 2009 at 7:09 PM, JC <> wrote:

> i have a dataset with month stored as a separate variable as mmm. > (JAN). > I need to convert this to a numeric field so that i can use the mdy > function. > > 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! >

Back to: Top of message | Previous page | Main SAS-L page