Hey,
I have the following problem. Let's suppose I have this data set
country A B C
Germany 5 6 7
New Zealand 4 5 3
England 3 4 2
And I want to rename A into Y1960, B into Y1961 and C into Y 1962
I was trying the following
foreach num of numlist 1960(1)1970 {
foreach var of varlist A-C {
rename `var' Y`num'
}
}
However, it does not work. It only renames A and stops then with the error "variable y1960" already defined. Does anyone has an idea?
Best,
Simeon
Related Posts with Running two loops
what does curly brackets mean in stata help files?I know square brackets mean optional components, vertical bar means OR, but what do curly brackets {…
How can I export both variable label and variable name to excel from stataHi everyone, I would like to export both variable label and variable name with data to excel from st…
comparing two resultsHi every one I got a revision regarding to my analysis result i showed my results by distinguishing …
Measuring change in logistic random effects modelHi! I am doing a longitudinal analysis on the effects of firm contexts/practices on employees' rela…
Creating output table with interquartile range of Y after regression Code: sysuse auto.dta, clear eststo: ivreghdfe mpg (weight=trunk) foreign [aw=length] estadd ysumm…
Subscribe to:
Post Comments (Atom)
0 Response to Running two loops
Post a Comment