DATA Step, Macro, Functions and more

combining two datasets

Posts: 54

combining two datasets

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;

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.
Valued Guide
Posts: 2,191

Re: combining two datasets

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?

Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation