BookmarkSubscribeRSS Feed
GeetVish
Calcite | Level 5

Hello All

 I am trying to append two datasets and i am having an error saying XY variables has been defined as both charcter and numeric. The values are all numeric and some missing like blanks and dots but i want to be numeric.Kindly help, please see the code below with the error message :-

 

Data abc;
 set sourc.data1 sourc.data2;
 Result=input(XY ,best.);
run;

 

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

 

WARNING: Variable Result has already been defined as numeric. 

10 REPLIES 10
PeterClemmensen
Tourmaline | Level 20

The error message pretty much says it all. Please run this

 

proc contents data=sourc.data1;
run;

proc contents data=sourc.data2;
run;

and see the variables section. Then convert the XY variable in one of the data sets accordingly. 

 

@GeetVish , please let me know if this solved your problem or you need further assistance. Remember that the INPUT Function requires a character argument 🙂

GeetVish
Calcite | Level 5
H dray
I am getting all the values as dots now.:(
PeterClemmensen
Tourmaline | Level 20

Please be more specific about what you did and what your data looks like. Did you convert a variable? And what does your log say now?

GeetVish
Calcite | Level 5

Sorry i am working and messaging thats why its short.

So i found which data set has character variables and i am converting that into numeric. I have the variable values as yes , No, slight, exactly and many numbers . When i did the input(XY, best.) i am getting the new variable as just dots.

PeterClemmensen
Tourmaline | Level 20

Can you show me some of your data? Please run

 


proc print data=sourc.data1;
run;

and post the result..

PeterClemmensen
Tourmaline | Level 20

So that is your XY variable or? It is clearly a character variable. It makes no sense to represent these values as numbers. 

 

I may misunderstand you requirement entirely. However, please be more specific if you want a usable code answer. 

GeetVish
Calcite | Level 5
Yes its my XY variable. i need all the values to stay same and need to be in numeric way.
PeterClemmensen
Tourmaline | Level 20

First of all, I can barely see any of your data in the attached file.

 

But let's take a value that I actually can see. You have a character value of "value=60-177". What do you want the numerical representation of that value to be? The data seems very unstructured and you can not simply represent the variable XY as numbers.

GeetVish
Calcite | Level 5
Ok i will think and let you know. Thanks for your guidance .Will come again

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 4531 views
  • 1 like
  • 2 in conversation