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?
Content-Type: text/plain; charset="us-ascii"
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.
Investment Business Intelligence
Investment Management & Research
Global Leaders in Multi-Manager Investing
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Sent: Thursday, October 01, 2009 11:38 AM
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:
create view myVW as select item,input(value,$8.) as value from