Hi everyone!
I have a variable named "n_sector" which receives value from 35 to 98. Now I want to classify the values of this variable into 10 groups (which means I want to replace the value of this variable so that there are only 10 values: SA, SB..... SL), according to this criterion:
I want to repeat this command for 64 provinces (64 province codes). Could you please help me with this? I guess that we need the loop here but I do not know how. I am a starter of SAtata. Thank you so much!
Here is a sample of my data set for province 01
I have a variable named "n_sector" which receives value from 35 to 98. Now I want to classify the values of this variable into 10 groups (which means I want to replace the value of this variable so that there are only 10 values: SA, SB..... SL), according to this criterion:
value range | new value |
35-50 (from 35 to 50) | SA |
51-55 | SB |
56 | SC |
57-58 | SD |
59-61 | SE |
62-69 | SF |
70-76 | SG |
77-86 | SH |
87-93 | SK |
94-98 | SL |
Here is a sample of my data set for province 01
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str2 province_code int n_sector "01" 53 "01" 78 "01" 49 "01" 94 "01" 76 "01" 76 "01" 69 "01" 76 "01" 44 "01" 56 "01" 49 "01" 92 "01" 42 "01" 77 "01" 76 "01" 54 "01" 94 "01" 48 "01" 56 "01" 53 "01" 92 "01" 76 "01" 53 "01" 81 "01" 94 "01" 49 "01" 53 "01" 66 "01" 76 "01" 90 "01" 94 "01" 76 "01" 71 "01" 76 "01" 94 "01" 54 "01" 76 "01" 53 "01" 91 "01" 81 "01" 76 "01" 53 "01" 76 "01" 76 "01" 53 "01" 94 "01" 87 "01" 76 "01" 94 "01" 97 "01" 57 "01" 73 "01" 98 "01" 98 "01" 94 "01" 96 "01" 76 "01" 94 "01" 76 "01" 53 "01" 63 "01" 94 "01" 76 "01" 76 "01" 82 "01" 74 "01" 69 "01" 94 "01" 86 "01" 53 "01" 94 "01" 69 "01" 94 "01" 76 "01" 98 "01" 66 "01" 76 "01" 53 "01" 76 "01" 71 "01" 51 "01" 93 "01" 66 "01" 73 "01" 77 "01" 69 "01" 92 "01" 92 "01" 67 "01" 56 "01" 92 "01" 66 "01" 92 "01" 80 "01" 92 "01" 90 "01" 69 "01" 76 "01" 66 "01" 92 end
Comment