Discussion:
How to convert Char to Numeric in Proc sql step
(too old to reply)
Yu Zhang
2006-12-20 23:00:09 UTC
Permalink
proc sql noprint;
create table v_bma_tot as
select distinct(count(compl ) ) as compl_count ,
calculated compl_count / &tot as put(perc,??8.),
"("!!put(calculated perc,best.) !!'%)' as col2
from v_bma_exc2 ;
quit;
hello guys I am trying to generate variable for a table like this
proc sql noprint;
create table v_bma_tot as
select distinct(count(compl ) ) as compl_count ,
calculated compl_count / &tot as perc,
"("!!calculated perc!!'%)' as col2
from v_bma_exc2 ;
quit;
it is complaing that I can use !! only on character but if I am try to
change it char it is not letting me do it
proc sql noprint;
create table v_bma_tot as
select distinct(count(compl ) ) as compl_count ,
calculated compl_count / &tot as put(perc,??8.),
"("!!calculated perc!!'%)' as col2
from v_bma_exc2 ;
quit;
Any suggestions to do it one step
thanks for the help
Howard Schreier <hs AT dc-sug DOT org>
2006-12-21 03:05:43 UTC
Permalink
hello guys I am trying to generate variable for a table like this
proc sql noprint;
create table v_bma_tot as
select distinct(count(compl ) ) as compl_count ,
calculated compl_count / &tot as perc,
"("!!calculated perc!!'%)' as col2
from v_bma_exc2 ;
quit;
it is complaing that I can use !! only on character but if I am try to
change it char it is not letting me do it
proc sql noprint;
create table v_bma_tot as
select distinct(count(compl ) ) as compl_count ,
calculated compl_count / &tot as put(perc,??8.),
You are confusing the *name* of the column and the *values* stored in a
column. "AS" is followed by the name of the column.
"("!!calculated perc!!'%)' as col2
from v_bma_exc2 ;
quit;
Any suggestions to do it one step
Try

put(calculated compl_count / &tot,??8.) as perc,

Or leave PERC as a numeric and instead code

"("!!put(calculated perc,??8.)!!'%)' as col2
thanks for the help
Loading...