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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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