02-23-2018 05:56 AM
I have recently moved from SAS EG 6.1 to SAS EG 7.1.
We use a macro which merges on some extra information based on postcode, which includes a variable called STHA. In many of our datasets, we already have STHA defned numerically (which we can format) but the Macro merges on a character variable named STHA.
In SAS EG 6.1 this returned an error (or warning maybe, I forget) that STHA has been defined as both character a numeric, but it would happily power through and keep going. Since moving to SAS EG 7.1, rather than powering through, it seems that the data step where STHA is merged on returns the same error/warning and returns an empty dataset (which causes the whole Macro to fall down).
Am I right in thinking that, as of SAS EG 7.1, merge won't work at all if any variables have been defined as both character and numeric? Or is something else likely to be at play here?
Thanks very much for your help.
02-23-2018 06:30 AM
I would guess that things transpired slightly differently. SAS would always generate an error if a variable were defined as numeric in one data set, but character in another data set. And that would take place without actually running the DATA step, since SAS needs to "decide" ahead of time what variables to use and what their characteristics should be.
Where you might see a difference depending on the release of the software is this. What should happen if a variable is character in all the incoming data sets, but has a shorter length in the first data set? In that case, the length would be set to the shorter length and it is conceivable that characters would be truncated from the second data set's values. In much earlier release of software, there would be no warning. Currently, you will receive a warning (with the possibility of an error ensuing during DATA step execution). In terms of release of SAS EG, I'm not sure when the change was introduced. Here's a paper that discusses the issue:
02-23-2018 06:33 AM
In any case, it is better not to rely on implicit conversion. Explicitely recoding the variable will
give you control over how exactly the merge will perform.