I have two sets of variables "within5km within10km within20km" and "less2plus 7 less2plus14 less2plus21 less2plus28". I would like to create new variables using a minimum value between the first set of variables and the second set of variables.
For example, egen exposure5_7 = rowmin( within5km Less2plus7), egen exposure5_14= rowmin( within5km Less2plus14)……………….
and so on, and egen exposure10_7= rowmin (within10km Less2plus7) and so on.
I am trying to create a loop but I am quite stuck with it. Any suggestion will be appreciated. Thanks in advance.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str10 date byte(within5km within10km within20km less2plus7 less2plus14 less2plus21 less2plus28) "2020-05-19" 7 10 0 0 2 8 9 "2020-05-20" 3 7 0 7 3 5 4 "2020-05-19" 9 10 6 0 2 9 0 "2020-05-19" 5 5 8 3 5 6 8 "2020-05-19" 2 6 7 7 0 5 3 "2020-05-19" 6 0 10 4 6 1 0 "2020-05-20" 0 2 2 4 0 8 0 "2020-05-20" 9 3 10 2 3 1 7 "2020-05-19" 0 10 9 0 2 7 5 "2020-05-19" 1 1 1 9 4 2 0 "2020-05-19" 7 4 1 0 0 5 8 "2020-05-19" 9 6 10 5 2 9 3 "2020-05-19" 0 7 4 5 2 7 4 "2020-05-18" 10 9 8 10 0 4 10 "2020-05-18" 0 7 9 5 8 4 5 "2020-05-22" 10 2 9 1 6 9 6 "2020-05-22" 10 6 10 2 9 3 1 "2020-05-22" 5 10 2 9 6 1 5 "2020-05-21" 2 6 0 6 7 8 1 "2020-05-21" 7 1 5 0 7 7 7 "19may2020" 4 4 9 10 6 5 10 "2020-05-25" 3 6 6 4 5 0 4 "2020-05-25" 5 3 6 0 3 0 10 "2020-05-25" 8 0 4 3 10 10 8 "2020-05-20" 8 3 5 4 2 10 0 "2020-05-25" 0 0 4 8 1 1 2 "" . . . . . . . "" . . . . . . . "" . . . . . . . "" . . . . . . . "" . . . . . . . "" . . . . . . . "" . . . . . . . "" . . . . . . . end
0 Response to generating multiple variables using multiple combinations of different variables
Post a Comment