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;
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;
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?
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.
to continuue @SASKiwi answer -
if you don't need those variables in output you can drop then from the inputs.
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?
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!
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.