input double(month202001 month202002 month202003 month202004 month202005 month202101 month202102 month202103 month202104 month202105 month202201 month202202 month202203 month202204 month202205)
276.16 275.63 276.83 278.39 273.53 290.03 290.3 291.96 293.88 287.92 307.02 308.21 310.12 312.38 309.28
300.11 299.13 300.74 303.39 294.08 315.81 315.35 317.32 320.28 308.41 333.51 334.95 337.43 340.25 334.02
245.46 245.49 246.17 246.34 247.17 256.97 258.18 259.44 260.02 261.65 273.05 273.93 275.11 276.64 277.57
290.95 291 291.44 291.49 291.72 301.15 302.12 303.73 304.23 305.17 321.57 323.49 325.31 328.18 329.4
224.99 225.06 225.93 226.04 226.3 229.98 229.35 229.5 229.44 225.9 233.53 233.65 234.17 234.65 235.01
285.35 284.83 285.51 285.79 285.8 297.45 299.53 302.63 305 306.46 320.51 322.05 323.51 325.93 328.4
232.8 232.88 233.28 233.7 239.36 249.01 250.79 251.13 251.5 251.53 253.44 253.57 253.91 254.59 255.05
248.96 249.14 249.97 250.22 252.04 269.58 272.6 274.68 276.02 294.86 315.7 317.11 317.88 319.82 320.76
190.66 190.69 190.92 190.96 190.96 194.13 195.12 195.89 195.95 195.99 203.16 203.76 204.95 206.59 207.47
262 262.23 263.15 263.41 263.66 291.53 296.15 299.06 299.67 299.99 312.88 314.16 317.85 319.99 321.15
end
[/CODE]
Above is the extract of my data, each variable is consumer price index (cpi) of each year and each month for ex month202001 is cpi of year2020 and month01, I want to create for year 2021 and 2022 the inflation rates for each month using the formula inf_202101=month202001-month202101/month202101, using foreach loop as I have many years in actual data set.
Related Posts with Loop over variables
merge dataHello everyone, sorry for asking many questions …
using egen to generate a variable based on a list of potential existing variablesHi all, I am relatively new to Stata and have a question regarding the generation of a new variable…
Fill column based on simple rulesSAMPLE DATA: Code: input person var1 1 1 1 2 1 . 1 3 1 1 1 4 2 2 2 2 2 . 2 . 2 3 2 3 3 3 3 4 3 . 3 …
Generate matching groupGood Morning/Afternoon, after conducting an event-study on two different groups of bonds (Green and…
PpmlDear Joao Santos Silva I have a panel data set with a count dependent variable and several count re…
Subscribe to:
Post Comments (Atom)
0 Response to Loop over variables
Post a Comment