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:         Thu, 1 Oct 2009 12:09:27 -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: how to convert a num. item to char in proc sql?
Comments: To: demin <qdmiris@GMAIL.COM>
In-Reply-To:  A<>
Content-Type: text/plain; charset="us-ascii"

Hi Demin,

You are very close.

the PUT function converts numeric to character the INPUT function converts character to numeric

input(oldvalue,$8.) as newvalue

is correct if you are converting numeric to character.


put(oldvalue,8.) as newvalue

to convert numeric to character.

Now for a gotcha: if you use

put(value,$8.) as value

you will still end up with a numeric variable even if the PUT converts it to character. The problem of using the SAME variable name is that once the variable type has been established by the compiler looking through all of the code prior to execution, what will happen is that the PUT() function will indeed convert to string but then the assignment(=) task is next and it will see that the new temporary intermediate string value will get converted (again) to the preexisting destination variable type. And in your case it ends up as numeric all over again. So check and use/re-use variable names accordingly.

Hope this is helpful.

Mark Terjeson Investment Business Intelligence Investment Management & Research Russell Investments 253-439-2367

Russell Global Leaders in Multi-Manager Investing

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of demin Sent: Thursday, October 01, 2009 11:38 AM To: SAS-L@LISTSERV.UGA.EDU Subject: how to convert a num. item to char in proc sql?

how to convert a num. item to char in proc sql?

I tried put, input, but doesn't work: proc sql; create view myVW as select item,input(value,$8.) as value from mytable where statistic='aaa'; quit;


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