BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

I have two data sets "data1" and "data2" and there are 3 variables in the data sets which are of same name but different type. These are:- variable1,variable2 and variable3 and these are NUM for dataset 2 and CHAR for dataset 1. How do I merge these datasets with different variable type??

I tried using INPUT and PUT but it didint work. Any suggestions?

Kind Regards,
Siddharth
1 REPLY 1
garybald
Calcite | Level 5
The first thing you need to decide is whether you want to keep the variables as numeric or character. Also consider if the variables are padded with leading zeros or anything else that may effect comparing the final values. Below is code I used to keep the variable NUMBER as a character when it was stored as numeric.

data temp (rename=(number2=number) drop=number);
length number2 $10;
set rev.mrc (keep = number);

number2 = put(number,z10.);

*NUMBER2 equals the numeric NUMBER with leading zeros. The original NUMBER is dropped, then NUMBER2 gets renamed to NUMBER in dataset temp.;

If you want to change the character variables to numeric, you can substitute code like this in the appropriate places:
length number2 8;
number2 = input(put(number,$10.),10.);
This converts the character to numeric.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 533 views
  • 0 likes
  • 2 in conversation