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
Esttab problem with interaction fixed effectHello, I am using a survey dataset (the World Values Survey) and trying out the following code in S…
Granger test and var (xtvar, prHi everyone, I am encountering a few problems when I tried to run var codes to be followed by a Gra…
GSEM in STATAHello. I'm a new user of STATA and struggle to get thinks done. I want to build a GSEM model where t…
use loop (e.g., foreach) across two vars to derive a third var (30 iterations)Hello All, I have 30 pairs of variables from which I need to derive 30 new variables. I'd like to u…
Problem in String Matching using listsI have sample individual addresses data which is pretty unclean. There more than 400000 observations…
Subscribe to:
Post Comments (Atom)
0 Response to forvalues
Post a Comment