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 (August 2008, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 28 Aug 2008 18:24:12 -0400
Reply-To:     "Howard Schreier <hs AT dc-sug DOT org>"
              <schreier.junk.mail@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Howard Schreier <hs AT dc-sug DOT org>"
              <schreier.junk.mail@GMAIL.COM>
Subject:      Re: Character values to month

On Thu, 28 Aug 2008 14:20:43 -0400, Nat Wooding <Nathaniel.Wooding@DOM.COM> wrote:

>By using a different format, one may eliminate the substr function . > >Data Mon; >Do Txt = '1' to '9'; > Mon3 = put(mdy(Txt,'1','1960'),worddate3.) ; > output; > end; > > proc print;run; > >I should point out that this solution will cause warning messages about >character to numeric conversion.

But not from MDY's reference to TXT, because TXT is a numeric variable (perhaps surprisingly; definitely contrary to the problem statement). Lose some of those messages by losing the quotes on the day and year constants.

I kind of like

Mon3 = put(input(catx('-',Txt,1,2345),mmddyy10.),monname3.) ;

even though it uses 3 functions.

> >ps, Ron: This solution uses 2 functions; yours has a whopping 3. > >Nat > >Nat Wooding >Environmental Specialist III >Dominion, Environmental Biology >4111 Castlewood Rd >Richmond, VA 23234 >Phone:804-271-5313, Fax: 804-271-2977 > > > > "Fehd, Ronald J. > (CDC/CCHIS/NCPHI) > " <rjf2@CDC.GOV> To > Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU > Discussion" cc > <SAS-L@LISTSERV.U > GA.EDU> Subject > Re: Character values to month > > 08/28/2008 11:52 > AM > > > Please respond to > "Fehd, Ronald J. > (CDC/CCHIS/NCPHI) > " <rjf2@CDC.GOV> > > > > > > >> From: DP >> >> Can anyone please tell me how to convert a character value to >> month? For >> instance, convert '1' to Jan, '2' to Feb, '3' to Mar, etc... >> One thing I can think of is to create a format and then apply >> the format to >> the variable. Is there another efficient way of doing this? > >you will have to use two function to do this > >convert string to date-number: mdy('1','1','1960') >convert date-number to string put(number,monyy.) > >untested > >Do Txt = '1' to '9'; > Mon3 = substr(put(mdy(Txt,'1','1960') > ,monyy.) > ,1,3); > end; > >Ron Fehd the macro maven CDC Atlanta GA USA RJF2 at cdc dot gov > > >CONFIDENTIALITY NOTICE: This electronic message contains >information which may be legally confidential and/or privileged and >does not in any case represent a firm ENERGY COMMODITY bid or offer >relating thereto which binds the sender without an additional >express written confirmation to that effect. The information is >intended solely for the individual or entity named above and access >by anyone else is unauthorized. If you are not the intended >recipient, any disclosure, copying, distribution, or use of the >contents of this information is prohibited and may be unlawful. If >you have received this electronic transmission in error, please >reply immediately to the sender that you have received the message >in error, and delete it. Thank you.


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