Help using Base SAS procedures

merging issue

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

merging issue

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

 


Accepted Solutions
Solution
‎02-09-2016 07:24 AM
Super User
Posts: 5,096

Re: merging issue

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


All Replies
Super User
Posts: 17,936

Re: merging issue

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?

Solution
‎02-09-2016 07:24 AM
Super User
Posts: 5,096

Re: merging issue

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.

New Contributor
Posts: 2

Re: merging issue

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

 

C

Respected Advisor
Posts: 4,659

Re: merging issue

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
☑ This topic is solved.

Need further help from the community? Please ask a new question.

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