I am not sure why I continue to get this error, as I have checked each dataset from Histo1 to Histo18 and ACR is numeric in all the datasets. Any help is much appreciated, thank you!
1461 Data Histo;
1462 length CR ID $12;
1463 Set HISTO1-HISTO18;
ERROR: Variable ACR has been defined as both character and numeric.
1464 CR = strip(CAT("CR",strip(put(ACR,best.))));
1465 Drop ACR;
1466 Run;
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.HISTO may be incomplete. When this step was stopped there were 0
observations and 6 variables.
WARNING: Data set WORK.HISTO was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.03 seconds
Alternatively you can also query dictionary.columns and find if all of them are numeric.
proc sql;
select distinct name,type
from dictionary.columns
where libname="WORK" and memname like 'HISTO%';
quit;
You can't just inspect the values to determine whether a variable is character or numeric. You need to run a PROC CONTENTS on each data set, and inspect the output.
SAS will be correct. You will have a mix where sometimes the variable is character and sometimes it is numeric.
Alternatively you can also query dictionary.columns and find if all of them are numeric.
proc sql;
select distinct name,type
from dictionary.columns
where libname="WORK" and memname like 'HISTO%';
quit;
Thank you, that helped a lot. I was able to find the one dataset that had it as a character. Thank you!
You will have this crop up moderately frequently if you are relying on Proc Import to read data sets into SAS.
Another frequent issue with Proc Import for multiple sets is the warning similar to:
WARNING: Multiple lengths were specified for the variable x by input data set(s).
This can cause truncation of data.
because each run of Proc Import guesses separately as to the appropriate length of variables and variable types.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.