Hello,
I use a macro to import 8 Excel files with 5 spreadsheets, then I combine all the sheets based on the different years. I found that I could not do the merge due to lots of variables are not in the same format. Please see the sample codes and error messages below.
%let Y1=1617;
%let Y2=1718;
%let Y3=1819;
%let X1=VAN;
%let X2=ROC;
%let X3=CIN;
%let X8=PIT;
%macro import;
%do i = 1 %to 3;
%do z = 1 %to 3;
PROC IMPORT OUT=&&X&i.._&&Y&z.
datafile="Pathwasy\Underly_Con_&&X&i.."
dbms=xlsx replace;
sheet=&&X&i.._&&Y&z..;
run;
%end;
%end;
%mend;
%import;
data underly_1617;
set cin_1617 hou_1617 kc_1617 pit_1617 roc_1617 sea_1617 van_1617;
run;
proc sort data=underly_1617; by studysite caseid; run;
Brief error messages are shown below, more than twenty variables had both character and numeric issues when I tried to merge in the last step. I am curious whether I should format those variables into numeric while I did the macro import; or get around of both character and numeric issue while I combine the subset. Please advise, thank you.
70 data underly_1617; 71 set cin_1617 roc_1617 van_1617; ERROR: Variable uapnea has been defined as both character and numeric. ERROR: Variable ugerd has been defined as both character and numeric. ERROR: Variable uprem has been defined as both character and numeric. ERROR: Variable ugestage has been defined as both character and numeric. 72 run;
NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.UNDERLY_1617 may be incomplete. When this step was stopped there were 0 observations and 49 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.01 seconds
... View more