I have 100 datasets in a library (called DATA). When I want to merger them into one dataset, SAS said some variables defined as both character and numeric. So I used following codes to modify the problem through change variables' format. However, SAS still reported the error: Variable has been defined as both character and numeric when I attempting to change their formats.
edit: I changed my code and use input
function to solve this problem. However, it reported same errors as shown in the pic:
%macro step1(sourcelib=,source=);
proc sql noprint; /*read datasets in a library*/
create table mytables as
select *
from dictionary.tables
where libname = &sourcelib
order by memname ;
select count(memname)
into:obs
from mytables;
%let obs=&obs.;
select memname
into : memname1-:memname&obs.
from mytables;
quit;
data
%do i=1 %to &obs.;
&source.&&memname&i
%end;
;
set
%do i=1 %to &obs.;
&source.&&memname&i
%end;
;
price1=input(price,best12.);
volume1=input(volume,best12.);
bid_imp__vol1=input(bid_imp__vol,best12.);
Ask_Imp__Vol1=input(Ask_Imp__Vol,best12.);
drop price volume bid_imp__vol ask_Imp__Vol;
run;
data
%do i=1 %to &obs.;
&source.&&memname&i
%end;
;
set
%do i=1 %to &obs.;
&source.&&memname&i
%end;
(rename=(price1=price volume1=volume bid_imp__vol1=bid_imp__vol Ask_Imp__Vol1=Ask_Imp__Vol));
run;
%mend;
%step1(sourcelib='DATA',source=DATA.);