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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 4 replies
  • 1014 views
  • 4 likes
  • 4 in conversation