Hi,
I have an Excel file with many variables and when I import it to SAS they are all of a character format. But among these variables there are many variables whose observartions are all numbers, but still their format is character.
SAS gives an example on how to convert all character variables to numeric
http://support.sas.com/kb/40/700.html
proc contents data=test out=vars(keep=name type) noprint;
run;
data vars;
set vars;
if type=2 ;
newname=trim(left(name))||"_n";
run;
proc sql ;
select trim(left(name)), trim(left(newname)),
trim(left(newname))||'='||trim(left(name))
into :c_list separated by ' ', :n_list separated by ' ',
:renam_list separated by ' '
from vars;
quit;
data test2;
set test;
array ch(*) $ &c_list;
array nu(*) &n_list;
do i = 1 to dim(ch);
nu(i)=input(ch(i),8.);
end;
drop i &c_list;
rename &renam_list;
run;
But the above code converts to numeric even variables that should be character.
So is it possible for SAS to know automatically which characters should be converted to numeric and which should not?
Thank you!
... View more