BookmarkSubscribeRSS Feed
Daily1
Quartz | Level 8

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.	

2 REPLIES 2
PaigeMiller
Diamond | Level 26

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;

 

 

--
Paige Miller
Kurt_Bremser
Super User

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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 924 views
  • 3 likes
  • 3 in conversation