SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Numeric and character

Reply
Contributor
Posts: 67

Numeric and character

Hi guys 

I got this error when I wanted to set tow datasets together ( ERROR: VARIABLE CALVING_EASE HAS BEEN DEFINED AS BOTH CHARACTER AND NUMERIC  ) 

 

DATA ALL;
SET DATA9 DATA10;
RUN;

 the variable calving_ease was having NA DATA I hade changed to missing data by using this second code and I still having the same issue 

data want;
set mfd4;
if anyalpha(calving_ease) then call missing(calving_ease);
run;

 What can I do for this situation? 

Regards 

Super User
Posts: 9,932

Re: Numeric and character

call missing does not change the type of a variable, it just either sets to a numeric missing or blanks for character variables.

You need to do a conversion in one of your datasets.

Still better is to look where the variable is created in the first place, and make the correction there.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Posts: 6,644

Re: Numeric and character

I gave you the right approach when you posted the earlier problem here:

 

https://communities.sas.com/t5/SAS-Data-Management/Convert-character-to-numeric/m-p/453299

 

The solution you chose did not convert from character to numeric, hence the current problem.

Frequent Contributor
Posts: 79

Re: Numeric and character

data9 and data10 has VARIABLE CALVING_EASE of different types.

One is having character and other is numeric. So when you try to concatenated them using 'set' statement, it throws error that the data type is different.

 

You need to change the datatype of the said variable in one of the dataset so that it is in line with the other one.


Cheers from India!

Manjeet
Ask a Question
Discussion stats
  • 3 replies
  • 114 views
  • 0 likes
  • 4 in conversation