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
What the log says: duid is character in one dataset, and numeric in the other.
Run PROC CONTENTS for each dataset and look at the output.
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
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.
You need to make duid the same type in both datasets. Either make them both numeric or both character.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.