BookmarkSubscribeRSS Feed
pammers
Calcite | Level 5

I am trying to merge two files into a new combined file. Both files have many of the same variables. I am getting an error message on merging that says something to the effect "variables are both character and numeric." For example, there is one variable called "extract_month." In one file it is listed as "char" and in the other "numeric".  (no idea how this happened!). I went into the attributes to change one from char to numeric but I can't change. I am only assuming this is the only problem with the merge. Any idea how to fix it? Thanks!

2 REPLIES 2
Reeza
Super User

You can't change a variable type once it exists. You can drop the variable and recreate it however as a character/numeric. 

However, it's usually easier to go back in your steps and fix that variable from the start. 

 

Should the variable be numeric or character is the first question? - that's a business use/knowledge question that we can't answer

Why isn't it the correct type? - import from Excel where it assumed types, or from PROC IMPORT?

Where to fix it? - Ideally in the import step but you can also fix it after the fact. 

 

If you do a SQL merge you can fix it in the join directly as well.

BrunoMueller
SAS Super FREQ

You have to convert one of the variables, so that both have the same type.

 

See http://support.sas.com/kb/24/590.html and https://blogs.sas.com/content/sgf/2017/03/28/changing-variable-type-and-variable-length-in-sas-datas...

 

Also check the programs that created the two datasets, maybe you can already change it there.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 711 views
  • 0 likes
  • 3 in conversation