Hi
I am running Stata 15.1 on a Windows 7 8 core desktop. I am trying to run postfile but keep getting the following error
postfile __000000 already exists
The data is one row per individual and a
ID Study HomeMed_affect_drug HomeMed_mood_drug HomeMed_adhd_drug HomeMed_any_psych_drug HomeMed_any_benzo
123 1 1 1 0 1 1
The problematic code is below
version 15.1
tempname handle
loc nlist "HomeMed_affect_drug HomeMed_mood_drug HomeMed_adhd_drug"
di "`nlist'"
foreach x of local nlist {
di "`x'"
forvalues f=1/16 {
postfile `handle' draw `x'_pop `x'_sample_1 `x'_sample_0 `x'_rp using `x'test1 ,replace every(1)
count if `x' ==0 & draw ==`f'
loc `x'_sample_0 =r(N)
count if `x'==1 & draw ==`f'
loc `x'_sample_1= r(N)
count if `x'==1
loc `x'_pop =r(N)
tab `x' study_subject if draw ==`f' |draw ==. ,ex
loc `x'_rp =r(p_exact)
post `handle' (`f') (``x'_pop') ( ``x'_sample_1') (``x'_sample_0') ( ``x'_rp')
}
}
postclose `handle'
I tried inserting a postutil clear statement before the postfile command per a statalist poster but it results in only a single row being posted. A version of this code with just one variable works without problems and saves 16 rows to the posted file.
Has anyone encountered this before and come up with a solution? In the example, I have listed 4 variables but I have more than 4 in the full dataset.
Many thanks
Paul
Paul Walsh
Related Posts with Postfile __000000 already exists
extract scoresHello, I hope someone can help me with this question. The sample dataset is as in the attachment. I'…
Changing axis labels using mrgraph command (mrtab module)I have been using the mrgraph command from the mrtab module to help deal with multiple response ques…
2sls regressionGood afternoon. I have a dataset with these information: - education: dummy skilled/not skilled - A…
Year omitted becuase of collinearity (DID)Hi, I am doing DID regression. I have 12 years of data. I have included 'year' variable for fixed y…
Marginal effect analysishello I want to estimate the marginal effect of an independent variable, pp after a logistic regress…
Subscribe to:
Post Comments (Atom)
0 Response to Postfile __000000 already exists
Post a Comment