Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Question about local in post command


From   Thomas de Hoop <[email protected]>
To   [email protected]
Subject   st: Question about local in post command
Date   Thu, 07 Aug 2008 15:43:14 +0200

Dear all,

I am currently creating several datasets to be used later. I am running 65 stepwise regressions. Each variable is the dependent variable one time. I want to create a dataset wherein the coefficients of each variable are created as variables. Later I want to impute missing values in my dataset for consumption. For my analysis I only want to use the variables that have a significant effect in the stepwise regression results. Later I will create dummy variables for the variables that have a significant effect.

With help of these dummy variables I can later impute my missing values with help of the significant variables in the stepwise regression ( if dummy==1). This is not where my question is about but serves as background info.




I have a problem with the post command to create my datasets:


I programmed my do file as follows:

forval i=1/65 {
postfile post`i' `dr`i'' using "C:\Documents and Settings\Thomas\Mijn documenten\Radboud Universiteit Nijmegen\Promotie\Data\Bolgatanga\Statafiles\post`i'", replace

sw, pr(.05): regress var`i' `dr`i''


local local (`b_var1') (`b_var2') (`b_var3') (`b_var4') (`b_var5') (`b_var6') (`b_var7') (`b_var8') (`b_var9') (`b_var10') (`b_var11') (`b_var12') (`b_var13') (`b_var14') (`b_var15') (`b_var16') (`b_var17') (`b_var18') (`b_var19') (`b_var20') (`b_var21') (`b_var22') (`b_var23') (`b_var24') (`b_var25') (`b_var26') (`b_var27') (`b_var28') (`b_var29') (`b_var30') (`b_var31') (`b_var32') (`b_var33') (`b_var34') (`b_var35') (`b_var36') (`b_var37') (`b_var38') (`b_var39') (`b_var40') (`b_var41') (`b_var42') (`b_var43') (`b_var44') (`b_var45') (`b_var46') (`b_var47') (`b_var48') (`b_var49') (`b_var50') (`b_var51') (`b_var52') (`b_var53') (`b_var54') (`b_var55') (`b_var56') (`b_var57') (`b_var58') (`b_var59') (`b_var60') (`b_var61') (`b_var62') (`b_var63') (`b_var64') (`b_var65')
foreach j of varlist `dr`i'' {
cap local b_`j'=_b[`j']
if _rc {
local b_`j'=.
}


post post`i' `local'

postclose post`i'
}
}

invalid syntax
post: above message corresponds to expression 1, variable var2


dr`i' are 65 locals consisting of different combinations of var1 till var65 wherein the dependent variable is not in the local. I created the local to create coefficient variables for all 65 regressions. The foreach command serves to create missings for the variables that are not included as significant variables in the stepwise regression. This command comes from an earlier post in the statalist on http://www.stata.com/statalist/archive/2005-03/msg00009.html.

The mistake is in post post`i' `local'.

It states the following: invalid syntax
post: above message corresponds to expression 1, variable var2

Can somebody please tell me what I did wrong in my commands.

Thanks in advance

Thomas de Hoop

*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index