Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Programing error


From   Eduardo Nunez <enunezb@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Programing error
Date   Tue, 24 Nov 2009 09:35:03 -0500

Dear Statalister,

Please, I need help with the following:
I am trying to export colpercent data from a 2x2 table into a word
document using the following formatting:

Variables                      SR (acxfa==0)
        AF (acxfa==1)
                                N          colpercent
            N          colpercent            P-value

exitus_all N (%)       174            34.7
     110               33.9                0.818
Variable 2...........................................................................................................................
Others variables..................................................................................................................

The 2x2 table for the first variables is below:

. tab exitus_all acxfa, m col chi2

+-------------------+
| Key               |
|-------------------|
|     frequency     |
| column percentage |
+-------------------+

           |         acxfa
exitus_all |         0          1 |     Total
-----------+----------------------+----------
         0 |       327        214 |       541
           |     65.27      66.05 |     65.58
-----------+----------------------+----------
         1 |       174        110 |       284
           |     34.73      33.95 |     34.42
-----------+----------------------+----------
     Total |       501        324 |       825
           |    100.00     100.00 |    100.00

          Pearson chi2(1) =   0.0530   Pr = 0.818



This is the program I have tried:
-----------------------------------------------------------------------------------------------------------------------------------
use "C:\Users\Eduardo\Desktop\ACXFA\Analysis\Cox_version_AHFi_June HR
and AF.dta"

tempname hdle

capt erase info.dta

postfile `hdle' str10 var sr_freq sr_colperc /*
*/  af_freq af_colperc overallfreq overallcolperc/*
*/ using info


foreach var of varlist exitus_all rehosp rehosp_HF sudden_death
hf_death othercvdeaths CV_death nonCV_death unknown_death {
       sum `var' if acxfa==0
       loc sr_freq=r(N)
       loc sr_colperc=r(mean)
       sum `var' if acxfa==1
       loc af_freq=r(N)
       loc af_colperc=r(mean)
       tab `var' acxfa, chi2
       local pval=r(p_lr)
       sum `var'
       post `hdle' ("`var'") (`sr_freq') (`sr_colperc') /*
       */ (`af_freq') (`af_colperc') (`pval') /*
       */ (r(N)) (r(mean))
}

postclose `hdle'

use info, clear
l, abbrev(12) noobs sep(0)

--------------------------------------------------------------------------------------------------------------------------------------

This is the error message I get:
post:  7 expressions expected and more than 7 found
r(198);

end of do-file


I would appreciate any suggestion.
Thank you in advance,

Eduardo
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index