I am trying to convert some long lists of values in Excel and I basically need to create a long list of foreach and forvalues loops which I will then transfer to STATA to execute. When I try to program a loop in one single line, I keep getting 'program error: code follows on the same line as open brace'. Is there a delimiter I could put in the code so I can keep it in one line. This is the code I am trying to use. Sorry but I am a bit rusty in my STATA.
foreach i = "C30.0", "C31" {forvalues j = 8004, 8032, 8050(1)8076, 8078, 8083(1)8084, 8123, 8560, 8980 {display `i';",";`j' } }
Thanks again
Neville
Related Posts with forvalues or foreach loop in one line of code
Problem setting base category in interaction termHi everyone, I have a question about choosing the base level of a factor variable in an interaction …
Quintile SortingHello I have a dataset of investment funds and want to divide the variable Turnover into 5 quintiles…
Fixed effects model drops all variables due to collinearityI am trying to do a fixed effects regression on survey data, however when I do so all the variables …
Repeated cross-section: gen new variable combining three survey yearsHello, In order to obtain repeated cross-sectional data, I have appended 3 datasets stemming from d…
Adjust for time constant covariate in mixed effects regression using multiple imputationI would like to ask for advice regarding the following question: I would like to compute a mixed eff…
Subscribe to:
Post Comments (Atom)
0 Response to forvalues or foreach loop in one line of code
Post a Comment