Hello,
I am having difficulty creating dummy variables from a dataset that I have downloaded. My dataset has the variable "sex" listed as either "1 MALE" or "2 FEMALE" and I want to convert these into just 1 or 2. I tried using the code (replace sex=1 if sex=="1 MALE") but I keep getting the error type mismatch r(109) which I understand means I am attempting to convert two different types of data. The data was originally in the "double" type and I have tried to convert it into all of the other storage types (float, double, long, int, byte) but I still get the same error message for type mismatch. I have watched many videos but I can't figure out how to convert this data into dummy variables. If anyone can advise on how to do this it would be much appreciated.
I am having difficulty creating dummy variables from a dataset that I have downloaded. My dataset has the variable "sex" listed as either "1 MALE" or "2 FEMALE" and I want to convert these into just 1 or 2. I tried using the code (replace sex=1 if sex=="1 MALE") but I keep getting the error type mismatch r(109) which I understand means I am attempting to convert two different types of data. The data was originally in the "double" type and I have tried to convert it into all of the other storage types (float, double, long, int, byte) but I still get the same error message for type mismatch. I have watched many videos but I can't figure out how to convert this data into dummy variables. If anyone can advise on how to do this it would be much appreciated.
Comment