Consider the following panel data that tracks each agent's salary information in some form (e.g., annual, post-tax).
I want to create a new variable -salary- for each observation that puts -hourly- wage information when both -annual- and -posttax- entries are missing.
If one of -annual- or -posttax- has a valid entry, I want to put -posttax- in the -salary-.
How would I go about doing this for each observation in a loop? Also, although the example above does not have string variables, I want to do the same excerise as if these variables are all string (e.g., city, state, country, geographic information).
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int(id recordyr) byte salary long(annual posttax) float hourly 112 2001 . 50000 46000 . 112 2002 . . . 17 113 2002 . . 32000 . 113 2003 . . 33500 . 113 2004 . . . 17.88 end
If one of -annual- or -posttax- has a valid entry, I want to put -posttax- in the -salary-.
How would I go about doing this for each observation in a loop? Also, although the example above does not have string variables, I want to do the same excerise as if these variables are all string (e.g., city, state, country, geographic information).
Comment