I would like to write a code with two -foreach-, onde inside the other. However, I would like the list of the second foreach to vary acording to the value of the first foreach.
I need to change the second line below in order to make the list vary acording to `u'. Does anyone know how could I do so?
I need to change the second line below in order to make the list vary acording to `u'. Does anyone know how could I do so?
Code:
foreach u in SP MG { foreach y of LIST VARYING ACORDING TO SP OR MG { foreach x in 1s 2s{ use PAMG`y'_`x', clear keep dt_proc cnes08 mun_cnes cod_proc08 qt_prod gen tp_proc = 1 if inlist(cod_proc08,101010010,101030010,301010137,301050058) replace tp_proc = 2 if inlist(cod_proc08,301010030,301010064) replace tp_proc = 3 if cod_proc08==301010110 replace tp_proc = 4 if cod_proc08==310010012 drop cod_proc08 *mantendo apenas os procedimentos acima com municipio do cnes informado drop if tp_proc==. | mun_cnes==. save PA`u'`y'_`x'_temp } } }
Comment