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?

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 1266 views
  • 0 likes
  • 4 in conversation