I am trying to respect the rules/norms of this forum, but I didn't feel dataex did much good in this case. I am trying to run a regression and correlation by state. I have a variable state_num with Alabama=1 Alaska =2, etc... I input
forvalues state_num 1/51 {
regress edge percentFRL
correlate edge percentFRL
}
I have more commands than that, but that gives you the idea. The output is giving me 51 of the same thing (ALL Alabama) I'm assuming because it is taking from the first 51 observations instead of each value of state_num representing each state. I have tried foreach as well, but can't seem to get the syntax correct.
Something to maybe note is how I generated state_num is by egen state_num = group(state) Could that have something to do with it? I used encode once upon a time, and it worked, but for some reason some how went back to state name instead of state number, albeit no longer in string format.
I am very much a novice and just picked stata back up after 13 years of not touching it. Some has come back to me, and I am trying so hard to figure things out on my own before coming here (including buying books on my kindle authored by some of you who are always so helpful on here), but I can't figure this out.
Related Posts with forvalues
Help require with Syntax of PPVT (cognitive test) scoring of Young LivesHi, I needed help with the syntax of converting cognitive raw scores of the cognitive test (PPVT) wi…
Mixed vs fixed effects linear regression modelsDear all, I would like to thank you in advance, I am a new user of Stata and I have some trouble ana…
Drawing a sample from dataset.Hi everyone, I have dataset on enterprises which are categorized by sectors and regions. I wanted to…
Kruskal-Wallis H test with Binary Variable across multiple groupsHi; I am a qualitative researcher who is relatively new to STATA. I have found reading this forum ve…
Converting to string with values equal to previous numeric labelsFor all the variables in a dataset that have value labels, I would like to make those variables stri…
Subscribe to:
Post Comments (Atom)
0 Response to forvalues
Post a Comment