Hi,
I have a number of datasets (ds1, ds2, ds3, etc) that I want to append. However, several variables have different types (i.e. character or numeric) in different datasets, so when I use:
data new;
set ds:;
run;
I get the error message "Variable var1 has been defined as both character and numeric" etc.
Is there a way to append the datasets and have all the variables without manually changing their types? They could all be stored as character
Best
Is there a way to append the datasets without changing types?
NO, same variable cannot have different types.
Decide which type is proffered and change the type on the appropriate datasets or rename them to have different names.
One of the most common causes of this is use of Proc Import to read data. That means that you have no control over the variable types or lengths. If these data sets are supposed to be of the same structure you will be better off the long run by reading the data as needed, likely with a data step.
You can also have issues with variables of the same type with different lengths. So if you are seeing notes related to that then you should also fix the length issues before combining the data.
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.