Hi guys,
I would like to make a loop that includes several different variables for different databases. Let's say I have DB1, DB2, DB3 corresponding to 3 different aggregations (product, firm, market). For each level some of the variables I will create are similar and just differ for the names (e.g. gr_rate_product, gr_rate_firm, gr_rate_atc2) so that I can just change the name in the loop like this for instance: gr_rate_`i' . However some of the variables are specific for each level and are not included in other levels (e.g. for market database there is a variable called share_off_generics which does not appear neither in DB1 nor in DB2 and that cannot be created with the data contained in such DBs). My aim is to perform 3 regression with all the variables of the 3 DBs and include them in a single loop. So something like:
reg gr_rate`i' var1_`i' var2 if DB = DB1
reg gr_rate`i' var1_`i' var2 var3 if DB = DB2
reg gr_rate`i' var1_`i' var4 if DB = DB3
where var1_`i' denotes the generic variable in common and var2, var3, var4 are DB specific variables
Is there a way to do it?
Thanks a lot
Related Posts with Looping through different databases
Replacing missing variables in a data set with duplicate data by rowI am struggling to replace missing data with a particular value in my dataset which has multiple dup…
Matching: Removing reversed causality?Hi everybody, I've read that endogeneity has many faces: One is omitted variable bias, another is m…
SUREG t stat of two coefficientsI have two regression models: DV1 = bVOI1 + bVOI2 + bVOI3 + bVOI4 + Controls DV2 = aVOI1 + aVOI2 +…
Generating One Way Frequency Table in Stata for LatexHi, I am not sure about how to create oneway frequency table in Stata that I can export to Latex, sa…
insufficient observations r(2001);hello every one. I am using on cross-section data . but when I run regression I receive this error: …
Subscribe to:
Post Comments (Atom)
0 Response to Looping through different databases
Post a Comment