Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: How to make local condition for graph command


From   Caleb Southworth <[email protected]>
To   [email protected]
Subject   st: How to make local condition for graph command
Date   Sat, 8 Dec 2012 15:50:56 -0800

This code creates a table and Kaplan Meier graphs for five
event-history outcomes.

My problem is that under some circumstances, the 25th percentile is
undefined, so my -local p25- is undefined. This causes graph to crash
because I cannot specify a line at a missing value. Could someone
propose a work-around that is the logical equivalent of

local p25="" if missing(r(p25))

The crash occurs in the line "sts graph" when missing(r(p25))

begin code:

set more off
log using ${docpath}stdesc.txt, text replace
log off
local mean
local p25
assert event!=.&event<=5
forval i=1/5 {
	qui stset app_dt, fail(event==`i') id(Cin) origin(time td(1Jan2008)) noshow
	qui log on
	qui stdescribe
	di "event= " `i' " subjects= " r(N_sub) " failure= " r(N_fail) "
mean= " r(f_mean)
	qui log off
	qui stci, rmean
	local mean=round(r(rmean))
	qui stci, p(25)
	local p25=round(r(p25))
	sts graph, xline(`p25' `mean') xlab(0(300)1500 `p25' `mean',
angle(45)) saving(${gphpath}km`i'.gph, replace)
	}
log close

Here's the actual crash:

event= 4 subjects= 63399 failure= 696 mean= .01097809
invalid label specifier, :  . 1537:
r(198);

Thanks!

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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index