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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 1014 views
  • 3 likes
  • 3 in conversation