i have been working on a project where I need to merge data
so in one dataset longitude is in character format and in other its in numeric format.
When i try to convert the one in character to numeric the log says " numeric values have been converted to character"
Also i double checked , I m using the correct syntax for the conversion
new_variable = input(original_variable, informat.);
I dont know why then also it says numeric values have been converted to character
I am assuming there might be some observations in the variable which is character and rest are numeric?( although running proc contents show that the format for that particular variable is character)
SO how to look for those observations
There might be an easier way, but often in this situation I actually create a numeric var like so. I realize most people don't do this.
data want; set have;
numvar = .; /* create "empty" numvar */
numvar = charvar;
run;
If you do this, the numvar will return blanks "." for any charvar entries that aren't actually a number. So you can just pull up a list of the blanks, and review what they were in the corresponding charvar:
proc sql; create table numvar_blanks
as select
numvar,
charvar
from want
where numvar = .
/* optional */ and charvar ^= '';
quit;
Once you've sorted out what to do with any wonky cases, you can just drop the charvar and rename the numvar as desired, perhaps in the first datastep.
hi ,
it just creates two new variable numvar and charvar with all the observations as ' . '
" When i try to convert the one in character to numeric the log says " numeric values have been converted to character" "
Input function requires character values as the first parameter. If you see that message then the value/variable you provided is already numeric. So SAS has to convert it to character for the Input to work. So perhaps you are attempting to change the wrong variable?
Show us the results of running Proc Contents on BOTH data sets and tell us which ones are the ones you need to be the same.
NO variable in SAS will be both numeric and character. A value may be character and only hold digits but it is still character.
You also need to consider any FORMAT assigned to a variable. The value may look "character" if the format assigns text to numeric values. One not uncommon is to have a Sex or Gender variable with numeric values like 1 and 2 but a format that assigns more usable to humans of "Male" and "Female". Proc Contents will show the assigned format and if we see something with a non-SAS supplied name that could be the case with your data.
@pransh wrote:
I am assuming there might be some observations in the variable which is character and rest are numeric?( although running proc contents show that the format for that particular variable is character)
SO how to look for those observations
This has nothing to do with observations. In a SAS data set, a variable is either character for all observations, or numeric for all observations. As far as the rest of your questions, when there's something in the log that you don't understand, show us the ENTIRE log for this PROC or DATA step. Not small parts of the log, not the parts of the log that you think we need, show us the ENTIRE log for this PROC or DATA step.
Please copy the log as text and paste it into the window that appears when you click on the </> icon. DO NOT SKIP THIS STEP.
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.
Ready to level-up your skills? Choose your own adventure.