BookmarkSubscribeRSS Feed
Babloo
Rhodochrosite | Level 12

Appreciate if someone of you guide me to resolve the following error? Variable KNDBEG and KNDEIN has mentioned as character but the error says it is defined as both character and numeric. I'm not certain to debug this error and to resolve the issue. Value of KNDBEG and KNDEIN is '2018-01-01' and it is character.

 

6412       data _null_ (drop=knkvpb knkvpb_v);
6413          merge work.W72HMG0G(in=vorige)
6414                db2jr.TBFR10(in=huidige);
ERROR: Variable KNDBEG has been defined as both character and numeric.
ERROR: Variable KNDEIN has been defined as both character and numeric.
6415          by khiref;

 

5 REPLIES 5
SASKiwi
PROC Star

Run the following code and compare the definitions of kndbeg and kndein in each of your datasets.

 

proc contents data = work.w72hmg0g;
run;

proc contents data = db2jr.tbfr10;
run;

Babloo
Rhodochrosite | Level 12

Variables KNDBEG and KNDEIN are defined as numeric in db2jr.tbfr10. However I'm neither using these variables in my output nor in the selection.

 

May I know how I can resolve this error?

SASKiwi
PROC Star

You've just identified the problem: Variables KNDBEG and KNDEIN are defined as numeric in db2jr.tbfr10 and as character in the other dataset. They need to be the same type in both datasets for your MERGE to work.

Shmuel
Garnet | Level 18

to continuue @SASKiwi answer - 

if you don't need those variables in output you can drop then from the inputs.

Kurt_Bremser
Super User

It is always a VERY BAD IDEA to have identically named variables in both datasets of a merge, if they are not used as "by" variables.

Even if they are of the same type, which content will end up in the output is tricky to determine.

A situation like yours is usually the result of bad logic design, and a failure to know your data (Maxim 3).

 

And if those variables are not needed, why are they there at all?

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 5 replies
  • 774 views
  • 0 likes
  • 4 in conversation