BookmarkSubscribeRSS Feed
Barkamih
Pyrite | Level 9

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 

3 REPLIES 3
Kurt_Bremser
Super User

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.

Astounding
PROC Star

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.

mnjtrana
Pyrite | Level 9

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to connect to databases in SAS Viya

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.

Discussion stats
  • 3 replies
  • 675 views
  • 0 likes
  • 4 in conversation