Hello,
I want to generate following:
gen capm1 = rmrf if decile == 1
and this 10x times, basically until
gen capm10 = rmrf if decile == 10
Do I have to type this in 10x myself or can I use foreach? Is foreach possible with function gen, because the variablename has to change every time?
At the end I would also like to form 10 regressions looking like this, which is perhaps more possible with foreach? :
reg decile1 capm1 until reg decile10 capm10
Related Posts with Loop function
Laptop for running stataI am in the market for a new laptop that would allow me to run large datasets in Stata. Is an 8th ge…
Creating a dummy variable for each observation separatelyHello, I have a nummeric variable which is represented in % and I need to recode this variable. To …
Aggregating Data under serveral conditionsHej Statalist, I have a problem, as I want to aggregate my panel data under certrain conditions. I …
Weighted t testIs it possible to ttest a variable weighted by another variable in the dataset? So, to ttest the wei…
Create a variables based on consecutive years of observationDear Stata Users, Please, help me to resolve the following issue. Below is the sample of data that I…
Subscribe to:
Post Comments (Atom)
0 Response to Loop function
Post a Comment