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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.