Hi,
I have a simple problem, but I haven't been able to solve it yet. In my panel data, I want to make a homogeneous data set. There are a few variables that make indexes =100 with 2015, while others make indexes=100 with 2003. I would like to make all variable indexes=100 with 2015. In my following data, there is index=100 with 2003,
Using the "foreach" code, trying to generate the data,
"" foreach var of varlist inf {
egen t2015 = total(cond(year==2015,`var',0))
replace `var' = `var' * 400 / t2015
drop t2015
}"",
However, it seems to me what it generated is not the right approach to this case.
Thanks in advance for your advice.
------------------ copy up to and including the previous line ------------------
Listed 100 out of 1152 observations
Use the count() option to list more
I have a simple problem, but I haven't been able to solve it yet. In my panel data, I want to make a homogeneous data set. There are a few variables that make indexes =100 with 2015, while others make indexes=100 with 2003. I would like to make all variable indexes=100 with 2015. In my following data, there is index=100 with 2003,
Using the "foreach" code, trying to generate the data,
"" foreach var of varlist inf {
egen t2015 = total(cond(year==2015,`var',0))
replace `var' = `var' * 400 / t2015
drop t2015
}"",
However, it seems to me what it generated is not the right approach to this case.
Thanks in advance for your advice.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(id qdate) str103 industry double inf 1 172 "10. (Food Products)" 94.51333333333332 1 173 "10. (Food Products)" 98.79666666666667 1 174 "10. (Food Products)" 101.90333333333335 1 175 "10. (Food Products)" 104.78333333333335 1 176 "10. (Food Products)" 108.48333333333333 1 177 "10. (Food Products)" 112.86 1 178 "10. (Food Products)" 117.29 1 179 "10. (Food Products)" 119.81333333333333 1 180 "10. (Food Products)" 121.92999999999999 1 181 "10. (Food Products)" 122.86333333333333 1 182 "10. (Food Products)" 122.25 1 183 "10. (Food Products)" 121.33333333333333 1 184 "10. (Food Products)" 121.73 1 185 "10. (Food Products)" 120.49333333333334 1 186 "10. (Food Products)" 121.85333333333335 1 187 "10. (Food Products)" 124.68666666666667 1 188 "10. (Food Products)" 128.27666666666667 1 189 "10. (Food Products)" 131.27666666666664 1 190 "10. (Food Products)" 136.23999999999998 1 191 "10. (Food Products)" 143.15 1 192 "10. (Food Products)" 147.94333333333333 1 193 "10. (Food Products)" 156.71 1 194 "10. (Food Products)" 157.68333333333334 1 195 "10. (Food Products)" 156.44999999999996 1 196 "10. (Food Products)" 159 1 197 "10. (Food Products)" 161.32999999999998 1 198 "10. (Food Products)" 163.24333333333334 1 199 "10. (Food Products)" 168.29 1 200 "10. (Food Products)" 172.10333333333332 1 201 "10. (Food Products)" 174.62 1 202 "10. (Food Products)" 176.6966666666667 1 203 "10. (Food Products)" 179.03666666666666 1 204 "10. (Food Products)" 184.33666666666667 1 205 "10. (Food Products)" 187.25333333333333 1 206 "10. (Food Products)" 192.64999999999998 1 207 "10. (Food Products)" 200.29999999999998 1 208 "10. (Food Products)" 203.6966666666667 1 209 "10. (Food Products)" 206.33666666666667 1 210 "10. (Food Products)" 208.96666666666667 1 211 "10. (Food Products)" 212.24 1 212 "10. (Food Products)" 213.92 1 213 "10. (Food Products)" 217.82666666666668 1 214 "10. (Food Products)" 221.92333333333332 1 215 "10. (Food Products)" 226.96 1 216 "10. (Food Products)" 240.37666666666667 1 217 "10. (Food Products)" 252.15333333333334 1 218 "10. (Food Products)" 261.8933333333334 1 219 "10. (Food Products)" 268.65999999999997 1 220 "10. (Food Products)" 277.40333333333336 1 221 "10. (Food Products)" 287.62333333333333 1 222 "10. (Food Products)" 290.68666666666667 1 223 "10. (Food Products)" 286.24666666666667 1 224 "10. (Food Products)" 290.17333333333335 1 225 "10. (Food Products)" 296.1433333333334 1 226 "10. (Food Products)" 298.48333333333335 1 227 "10. (Food Products)" 301.75 1 228 "10. (Food Products)" 316.0233333333333 1 229 "10. (Food Products)" 324.35999999999996 1 230 "10. (Food Products)" 325.77 1 231 "10. (Food Products)" 321.2 1 232 "10. (Food Products)" 331.76 1 233 "10. (Food Products)" 356.1433333333334 1 234 "10. (Food Products)" 386.85999999999996 1 235 "10. (Food Products)" 409.2366666666667 1 236 "10. (Food Products)" 415.94666666666666 1 237 "10. (Food Products)" 452.77 1 238 "10. (Food Products)" 454.25666666666666 1 239 "10. (Food Products)" 454.31 1 240 "10. (Food Products)" 479.60999999999996 1 241 "10. (Food Products)" 499.8566666666666 1 242 "10. (Food Products)" 507.2133333333333 1 243 "10. (Food Products)" 558.7433333333332 2 172 "12. (Tobacco Products)" 91.97333333333334 2 173 "12. (Tobacco Products)" 96.22666666666665 2 174 "12. (Tobacco Products)" 103.90666666666668 2 175 "12. (Tobacco Products)" 107.88999999999999 2 176 "12. (Tobacco Products)" 102.46333333333332 2 177 "12. (Tobacco Products)" 102.2 2 178 "12. (Tobacco Products)" 100.17333333333333 2 179 "12. (Tobacco Products)" 109.41000000000001 2 180 "12. (Tobacco Products)" 94.25333333333333 2 181 "12. (Tobacco Products)" 91.11 2 182 "12. (Tobacco Products)" 104.31 2 183 "12. (Tobacco Products)" 110.56 2 184 "12. (Tobacco Products)" 123.20666666666666 2 185 "12. (Tobacco Products)" 123.69666666666667 2 186 "12. (Tobacco Products)" 123.67 2 187 "12. (Tobacco Products)" 123.67 2 188 "12. (Tobacco Products)" 125.86333333333334 2 189 "12. (Tobacco Products)" 125.84999999999998 2 190 "12. (Tobacco Products)" 125.84999999999998 2 191 "12. (Tobacco Products)" 127.03000000000002 2 192 "12. (Tobacco Products)" 125.43333333333334 2 193 "12. (Tobacco Products)" 125.42333333333333 2 194 "12. (Tobacco Products)" 125.42 2 195 "12. (Tobacco Products)" 125.42666666666668 2 196 "12. (Tobacco Products)" 129.94 2 197 "12. (Tobacco Products)" 136.77666666666667 2 198 "12. (Tobacco Products)" 141.53 2 199 "12. (Tobacco Products)" 141.53 end format %tq qdate
Listed 100 out of 1152 observations
Use the count() option to list more
Comment