BookmarkSubscribeRSS Feed
Sophie-Hughes
Calcite | Level 5

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.

2 REPLIES 2
Astounding
PROC Star

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:

 

http://www2.sas.com/proceedings/sugi28/098-28.pdf

 

gamotte
Rhodochrosite | Level 12

Hello,

 

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 2 replies
  • 1384 views
  • 1 like
  • 3 in conversation