BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jen123
Fluorite | Level 6

Here is my code:

data libname.file_combined;

set libname.file_a

libname.file_b;

run;

I tried to merge two files and got this error:

ERROR:  Variable X has been defined as both character and numeric.

ERROR:  Variable Y has been defined as both character and numeric.

ERROR:  Variable Z has been defined as both character and numeric.

Variables X, Y and Z has cells that are either numeric or alpha-numeric.  So my assumption is that I have to convert them to character.  I ran this code I got an error:  EXPECTING a FORMAT NAME.  It looks like SAS doesn't like the 5.

data file_a (drop=a_variablex);

set file_a (rename=(variablex=a_variablex));

variablex=input(a_variablex,5);

run;

Any advice/help is appreciated!

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

When using a Format you need to have a period at the end.

Try

variablex= input(a_variablex,f5.);

You may have done this already, but it may be a good idea to run Proc Compare to see which data set has the numeric and which has the character versions of the variables in question.

View solution in original post

3 REPLIES 3
ballardw
Super User

When using a Format you need to have a period at the end.

Try

variablex= input(a_variablex,f5.);

You may have done this already, but it may be a good idea to run Proc Compare to see which data set has the numeric and which has the character versions of the variables in question.

jen123
Fluorite | Level 6

I did a PROC COMPARE:  file_a = $5. (character) and file_b=BEST 12. (num)

I ran this code and still got the same error (Variable has been definted as both character and numeric).

data file_b (drop=a_variablex);

set file_b (rename=(variablex=a_variablex));

variablex=input(a_variablex,$5.);

run;

Thoughts???


ballardw
Super User

I would confirm that variablex is now a character variable. I suspect not. If not, try using variablex = put(a_variablex,f5.);

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 5195 views
  • 0 likes
  • 2 in conversation