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
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.
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.
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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.