Date: Fri, 29 Sep 2006 18:53:45 +0000
Reply-To: iw1junk@COMCAST.NET
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <iw1junk@COMCAST.NET>
Subject: Re: Question about PUT numeric into character in PROC SQL
Summary: PUT function always writes to character variable.
#iw-value=1
Youngshan,
You have a numeric variable so a numeric format is needed.
proc sql;
create table test2 as
select put(var,3.) as newvar
from test
;
quit ;
The DATA step worked because the format 3. was substituted for
$3. SQL is fussier. The message
WARNING: Variable var has already been defined as numeric.
should have tipped you off that something was wrong. Don't
ignore messages from the system.
Ian Whitlock
==============
Date: Fri, 29 Sep 2006 11:26:04 -0700
Reply-To: Yongshan Lin <yongshan.lin@GMAIL.COM>
Sender: "SAS(r) Discussion"
From: Yongshan Lin <yongshan.lin@GMAIL.COM>
Subject: Question about PUT numeric into character in PROC
SQL
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
* Hi all,
I got a simple question but don't know the answer.
I have a numeric variable and want to use PROC SQL to change it
into
character variable, but failed.
However when I use data step to do it, it works, as follows.
Any input will be appreciated. Thanks.
*********************************************;
data* test;
input var;
cards;
12
;
proc sql; create table test2 as select put(var,$3.) as newvar
from test;
*****This one does not work;
**
*data* test2;
set test;
newvar = put(var,$3.);
run;
**** This one works;
|