I have a variable called Q9 which has either identical string values or empty cells. I want to generate a new variable called employment which takes a value of 1 if Q9 has a string value or a value of 0 if Q9 has a blank cell. I used the following codes:
And got the following results:
By the way, empty cells in a string variable indicate missing values...right? I ran the following code to check, but it did not show the existence of any missing values!
Code:
encode Q9, gen(employment) probit dep_var employment indep_var1 indep_var2
Code:
Probit regression Number of obs = 318 LR chi2(2) = 6.91 Prob > chi2 = 0.0315 Log likelihood = -93.626457 Pseudo R2 = 0.0356 ------------------------------------------------------------------------------ dep_var | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- indep_var1 | .6149843 .2511377 2.45 0.014 .1227634 1.107205 indept_var2 | .1176468 .3881169 0.30 0.762 -.6430484 .878342 employment | 0 (omitted) _cons | .435061 .529323 0.82 0.411 -.602393 1.472515 ------------------------------------------------------------------------------ . end of do-file
Code:
di missing(Q9) 0
Comment