I am trying to generate a categorical variables using seven dummy variables that identify whether a woman experienced a certain type of domestic violence (i.e. kicked, pushed etc). I want to generate a categorical variables ranging from 1 to 7 such that women who experienced only 1 of these types of domestic violence would be coded 1, women who experienced any 2 of these types of domestic violence would be coded 2, women who experienced any 3 of these types would be coded 3 and so on and so forth. Is there a quick way of generating this variable?
The seven variables are: dvppush dvpslap dvppunch dvpchoke dvpkick dvpmsever dvplsever
Here is my data
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int year byte(dvppush dvpslap dvppunch dvpchoke dvpkick dvpmsever dvplsever) 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 1 1 0 0 0 0 1 2005 1 0 0 0 0 0 1 2005 0 0 0 0 0 0 0 2005 1 1 1 0 0 0 1 2005 0 1 0 0 0 0 1 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 1 0 0 0 0 1 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 1 1 0 0 0 0 1 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 1 1 0 0 0 0 1 2005 1 0 0 0 0 0 1 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 1 1 1 0 1 0 1 2005 0 1 0 0 0 0 1 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 1 1 0 1 0 1 2005 1 0 0 0 0 0 1 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 1 1 0 0 0 0 1 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 1 0 0 0 0 0 1 2005 0 0 0 0 0 0 0 2005 1 1 0 0 0 0 1 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 1 1 0 0 0 0 1 2005 0 1 0 0 0 0 1 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 1 0 0 0 0 0 1 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 1 1 1 0 1 0 1 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 1 1 1 0 1 1 1 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 1 0 0 0 0 1 2005 0 0 0 0 0 0 0 2005 1 1 1 0 0 0 1 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 1 1 0 0 0 0 1 2005 0 1 0 0 0 0 1 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 1 1 0 0 0 0 1 2005 0 0 0 0 0 0 0 2005 1 1 0 0 0 0 1 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 1 1 1 0 0 0 1 2005 1 1 1 0 0 0 1 2005 1 1 0 0 0 0 1 2005 0 0 0 0 0 0 0 2005 0 0 0 0 0 0 0 2005 0 1 0 0 0 0 1 2005 0 0 0 0 0 0 0 end label values year YEAR label def YEAR 2005 "2005", modify label values dvppush DVPPUSH label def DVPPUSH 0 "no", modify label def DVPPUSH 1 "yes", modify label values dvpslap DVPSLAP label def DVPSLAP 0 "no", modify label def DVPSLAP 1 "yes", modify label values dvppunch DVPPUNCH label def DVPPUNCH 0 "no", modify label def DVPPUNCH 1 "yes", modify label values dvpchoke DVPCHOKE label def DVPCHOKE 0 "no", modify label values dvpkick DVPKICK label def DVPKICK 0 "no", modify label def DVPKICK 1 "yes", modify label values dvpmsever DVPMSEVER label def DVPMSEVER 0 "no", modify label def DVPMSEVER 1 "yes", modify label values dvplsever DVPLSEVER label def DVPLSEVER 0 "no", modify label def DVPLSEVER 1 "yes", modify
0 Response to Generating a categorical variable
Post a Comment