BookmarkSubscribeRSS Feed
Aar684
Calcite | Level 5
Hi all,

This is probably a basic question, but I cannot seem to find the answer. I have 2 datasets, one is SAS dataset and the other is an .xls file. Both files have the same variables. I need to combine the two datasets into one. This is obviously very simple.

Data number3;
set number1 number2;
run;

However, one of the variables is assigned as both character and numeric, therefore not allowing the data to combine. Is there another way to combine these or is there a way to convert variables to char or numeric without changing the variable name? Thanks in advance for any help people can provide.
1 REPLY 1
Peter_C
Rhodochrosite | Level 12
the data step that does the combining can do the numeric to character conversion.
For example, suppose the sas data has a string containing a numeric key like credit card number (but shorter, say length 9), and excel provides that in a numeric column: [pre]data together ;
set sas_data excel_data( rename=( key=nkey) in= fromexcel);
if fromexcel then key= put( nkey, best9.);
drop nkey ;
run ;[/pre]
does this look like what's wanted?

PeterC

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 640 views
  • 0 likes
  • 2 in conversation