BookmarkSubscribeRSS Feed
stellapersis7
Obsidian | Level 7

Hi,

i have this 2 data sets to merge one full and only  'common'  records from another data set.

i have used :

data merge1;

merge FY1.H181 (in=x) MCF.H180 (in=y);

by duid;

if (x=1);

run;

I did this after sorting using proc sort.

it gives me an error  

 "Variable DUID has been defined as both character and numeric"

but that variable has only numeric in the dataset.

can you please help me resolve thsi.

thanks

5 REPLIES 5
stellapersis7
Obsidian | Level 7

HI thank you,

I did contents and yes, it has both charater and numeric like "prstx15".

now, how do i merge both datasets when it gives this error?

thanks in advance

 

Kurt_Bremser
Super User

In the SQL procedure, you can use functions in the ON clause of a JOIN, so you can do the conversion there "on the fly".

For a data step MERGE, you need to first run a conversion step before you sort and merge.

How you do that depends on how the data is stored as character. I recommend to convert the numbers to character, as key values are always better stored as character.

stellapersis7
Obsidian | Level 7
HI thank you,
I did contents and yes, it has both charater and numeric
now, how do i merge both datasets when it gives this error?
thanks in advance
tarheel13
Rhodochrosite | Level 12

You need to make duid the same type in both datasets. Either make them both numeric or both character.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1190 views
  • 2 likes
  • 3 in conversation