BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
C0003
Calcite | Level 5

Hi! I am a new-ish SAS user. I am trying to do a one-to-many data merge with two files in my work folder. However, I keep getting this error:

 

ERROR: Variable Type has been defined as both character and numeric.

 

However, the varaibles are exactly the same:

Name: NUMBER

Length: 8

Format: Best12

Informat: 12

Type: Numeric

 

I have tried multiplying NUMBER by one to be sure it is numeric or to see if it needed a reset of sorts, but that did not work

 

my sas code is this:

 

/* Sorting data and merging */
proc sort data = A; by NUMBER;
run;
proc sort data = B; by NUMBER;
run;
/*One to many data merge - NUMBER is numeric */
data Merged_A_B;
merge A (in = aaa) B (in = bbb);
by NUMBER;
if aaa*bbb = 0 then delete;
run;

 

I am thinking it may be how I am merging and I have looked online for help but was not able to find it. Help with this would be much appreciated!

 

C

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

This message is actually very specific.  There is no problem with the variable named NUMBER.  Rather, you have a variable named TYPE that is numeric in one of the data sets and character in the other.

View solution in original post

4 REPLIES 4
Reeza
Super User

Post your log and a proc contents for both data sets. 

Do you have any other variables that might have the same name in both data sets but different types?

Astounding
PROC Star

This message is actually very specific.  There is no problem with the variable named NUMBER.  Rather, you have a variable named TYPE that is numeric in one of the data sets and character in the other.

C0003
Calcite | Level 5

Thank you! This was the issue. I was able to correct it and it runs perfectly. Thanks again!!

 

C

PGStats
Opal | Level 21

You could replace the whole thing wth a single proc SQL step :

 

proc sql;
create table Merged_A_B as
select A.number, A.type,
	/* other variables from A. or from B. */
from A inner join B on A.number=B.number;
quit;
PG

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1464 views
  • 4 likes
  • 4 in conversation