Statalist


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

Re: st: using computed values with the immediate command


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   Re: st: using computed values with the immediate command
Date   Thu, 7 May 2009 01:13:45 +0200

<>


Well, Nick`s earlier advice remains completely valid, although you are right that -csi- checks internally for integers via

-confirm integer number 2-

which passes the test
and

-confirm integer number 2.0-

which does not...


Here is an example to play around with for those who are interested:

***
clear*
set obs 100

gen x=cond(_n<=_N/2,0,1)

gen y1=cond(_n<=_N/2,1,3)
gen y2=cond(_n<=_N/2,3,5)

sum y1 if x==1, mean
local a1 = round(r(mean),0) // round to create integers
sum y1 if x==0, mean
confirm integer number `r(mean)'
di in red _rc
loc b1=r(mean)
/*local b1 = round(r(mean),0)
*/
sum y2 if x==1, mean
local c1 = round(r(mean),0)
sum y2 if x==0, mean
local d1 = round(r(mean),0)

// set tr on
csi `a1' `b1' `c1' `d1'
***

HTH
Martin
_______________________
----- Original Message ----- From: "David Elliott" <[email protected]>
To: <[email protected]>
Sent: Thursday, May 07, 2009 12:54 AM
Subject: Re: st: using computed values with the immediate command


Stata is telling you what is wrong.  It has nothing to do with not
being able to store values.  I assume since you are asking for r(mean)
after -summarize- that you are saving a scalar float with several
decimal places.  However,  -csi- the routine expects an integer based
on count data.

The following will probably be complete nonsense statistically but
illustrates the point:
sum stots if heart==1
local a1 = round(r(mean),0) // round to create integers
sum stots if heart==0
local b1 = round(r(mean),0)
sum stotd if heart==1
local c1 = round(r(mean),0)
sum stotd if heart==0
local d1 = round(r(mean),0)
csi `a1' `b1' `c1' `d1'

Giving csi a scalar, even if it is an integer, doesn't work. Contrast
the results of:
-csi 2 4 6 8- versus -csi 2.0 4.0 6.0 8.0-


D. C. Elliott

*
*   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/


*
*   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