Help using Base SAS procedures

changing a variable attribute

Occasional Contributor
Posts: 9

changing a variable attribute

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!

Super User
Posts: 23,700

Re: changing a variable attribute

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.

Posts: 824

Re: changing a variable attribute

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


See and


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

Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation