Thanks; that's the nicest thing anyone's said to me all day. In this case all the credit really belongs to StataCorp.
Nick
[email protected]
Michael Eisenberg
Nick,
You are a genius.
Thank you so much.
On Wed, May 6, 2009 at 9:33 AM, Nick Cox <[email protected]> wrote:
> One way of doing this is to ensure that -csi- sees the values of the scalars, and not their names.
>
> csi `=a1' `=b1' `=c1' `=d1'
>
> does that, assuming that none of a1 etc. can be interpreted as variable names. Stata ensures that the expressions given are evaluated before their results are passed to -csi-.
>
> Note this short-cut
>
> sum stots if heart==1
> scalar a1 = r(mean)
> sum stots if heart==0
> scalar b1 = r(mean)
> sum stotd if heart==1
> scalar c1 = r(mean)
> sum stotd if heart==0
> csi `=a1' `=b1' `=c1' `r(mean)'
>
> Note, however, that I haven't checked whether there is a way of getting what you want directly from the four variables.
>
> Michael Eisenberg
>
> I am attempting to create a do file to calculate means of several
> variables and then use these values in the csi command.
>
> sum stots if heart==1
> scalar a1 = r(mean)
> sum stots if heart==0
> scalar b1 = r(mean)
> sum stotd if heart==1
> scalar c1 = r(mean)
> sum stotd if heart==0
> scalar d1 = r(mean)
>
> csi a1 b1 c1 d1
>
> I get an error that " 'a1' found where integer expected."
>
> I'm not sure using scalars is the right way to accomplish this task.
> Is there a way to use the computed results like r(mean) is immediate
> commands?
>
> If not, can anyone think of a way to do this without having to type in
> the individual numbers.
*
* 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/