Reputation: 203
This is occurring in SAS Studio. I'll keep this as simple as possible. This problem has been driving me crazy for hours now. I've searched for similar issues and found none involving datasets as simple as the ones I'm working with.
I have an existing dataset from earlier in the program. I have another dataset that I imported from an xls file. I'm trying to merge these two together based off the variable that SAS is telling me is defined as both character and numeric.
The character variable is a string of length 10 that is entirely numbers. It's a character variable because I need to retain leading zeros.
The following code is what I've done to absolutely ensure that each variable I want is a character. It still doesn't work:
DATA TEST1;
SET earlier_data;
TESTING=input(want,$10.);
RUN;
DATA TEST2;
SET xls_import;
TESTING=input(want,$10.);
RUN;
PROC SORT DATA=TEST1;
BY TESTING;
RUN;
PROC SORT DATA=TEST1;
BY TESTING;
RUN;
DATA TEST3;
MERGE TEST1 (in=a) TEST2 (in=b);
BY TESTING;
RUN;
Despite running a PROC CONTENTS on both data sets and confirming that TESTING is a character variable of length 10. I still get the error:
ERROR: Variable b has been defined as both character and numeric.
Any help would be greatly appreciated. Thank you.
Upvotes: 0
Views: 3332
Reputation: 51566
Do not use the name of an existing variable as the name you specify on the IN= dataset option.
Use a name that does not already exist in the data step.
DATA TEST3;
MERGE TEST1 (in=in_test1) TEST2 (in=in_test2);
BY TESTING;
RUN;
Upvotes: 1