How to append different data type tables
Table1
Name Type Length Format
id Numeric 8 BEST12.
prn Numeric 8 BEST12.
age Numeric 8 BEST12.
report_no Numeric 8 BEST12.
Table2
Name Type Length Format
id Numeric 8 BEST12.
prn Numeric 8 BEST12.
age Character 5 $CHAR1.
report_no Character 8 $CHAR1.
In table 2, you have to convert AGE to numeric before the append, and you have to convert REPORT_NO to numeric before the append.
However, you can't simply convert character variables to numeric. There's a two-step dance (rename then change type) that has to be done. (Cue the two-step music...)
data table2;
set table2(rename=(age=age1 report_no=report_no1));
age=input(age1,3.);
report_no=input(report_no1,best8.);
drop report_no1 age1;
run;
The real question: why do you have different attributes for identical data items?
This points to a faulty process for bringing data into your SAS environment.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.