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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 5 replies
  • 437 views
  • 2 likes
  • 3 in conversation