Hello Everyone
I have following data with three variables
1. State name
2. months data
3. Median for each month
Now I would like divide Median of 0 month for every other month
for example I have median of state A1 in month 0 is 3.7 that I need to divide for state A1 in month 1, 2, and so on., (3.7 is fixed for rest of the months for that state).
Likewise I have 25 states with 36 months data. I would like to go through a loop, Please advice me.
Need to create a new variable new_var that can take values as from 11 to 20 it has to be 4.2/3.7 and from 21-30 it has to be 5.1/3.7 like wise.
Thanks for you help.
I have following data with three variables
1. State name
2. months data
3. Median for each month
Now I would like divide Median of 0 month for every other month
for example I have median of state A1 in month 0 is 3.7 that I need to divide for state A1 in month 1, 2, and so on., (3.7 is fixed for rest of the months for that state).
Likewise I have 25 states with 36 months data. I would like to go through a loop, Please advice me.
Need to create a new variable new_var that can take values as from 11 to 20 it has to be 4.2/3.7 and from 21-30 it has to be 5.1/3.7 like wise.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str2 state byte months float median "A1" 0 3.7 "A1" 0 3.7 "A1" 0 3.7 "A1" 0 3.7 "A1" 0 3.7 "A1" 0 3.7 "A1" 0 3.7 "A1" 0 3.7 "A1" 0 3.7 "A1" 0 3.7 "A1" 1 4.2 "A1" 1 4.2 "A1" 1 4.2 "A1" 1 4.2 "A1" 1 4.2 "A1" 1 4.2 "A1" 1 4.2 "A1" 1 4.2 "A1" 1 4.2 "A1" 1 4.2 "A1" 2 5.1 "A1" 2 5.1 "A1" 2 5.1 "A1" 2 5.1 "A1" 2 5.1 "A1" 2 5.1 "A1" 2 5.1 "A1" 2 5.1 "A1" 2 5.1 "A1" 2 5.1 "A1" 3 5.6 "A1" 3 5.6 "A1" 3 5.6 "A1" 3 5.6 "A1" 3 5.6 "A1" 3 5.6 "A1" 3 5.6 "A1" 3 5.6 "A1" 3 5.6 "A1" 3 5.6 "A2" 0 3.3 "A2" 0 3.3 "A2" 0 3.3 "A2" 0 3.3 "A2" 0 3.3 "A2" 0 3.3 "A2" 0 3.3 "A2" 0 3.3 "A2" 0 3.3 "A2" 0 3.3 "A2" 1 4.35 "A2" 1 4.35 "A2" 1 4.35 "A2" 1 4.35 "A2" 1 4.35 "A2" 1 4.35 "A2" 1 4.35 "A2" 1 4.35 "A2" 1 4.35 "A2" 1 4.35 "A2" 2 4.8 "A2" 2 4.8 "A2" 2 4.8 "A2" 2 4.8 "A2" 2 4.8 "A2" 2 4.8 "A2" 2 4.8 "A2" 2 4.8 "A2" 2 4.8 "A2" 2 4.8 "A2" 3 5.6 "A2" 3 5.6 "A2" 3 5.6 "A2" 3 5.6 "A2" 3 5.6 "A2" 3 5.6 "A2" 3 5.6 "A2" 3 5.6 "A2" 3 5.6 "A2" 3 5.6 end
Comment