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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 543 views
  • 0 likes
  • 2 in conversation