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
Opal | Level 21

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
Opal | Level 21

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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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