hi, how do I subset variable based on the observations within it ,For example (having malaria and not having malaria).Please help.I have really struggled
-
Login or Register
- Log in with
gen has_malaria = 1 if strpos(diseases_person_had, strupper("malaria")) > 0
* NOTE: strpos is case sensitive, so "Malaria" is different from "malaria"
* Assume the numeric variable with the response is response_var
tostring response_var, gen(response_var_string)
gen first_digit = substr(response_var_string, 1, 1)
destring first_digit, replace
Comment