⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stgen.hlp

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 HLP
字号:
{smcl}
{* 14mar2005}{...}
{cmd:help stgen} {right:dialog:  {bf:{dialog stgen}}}
{hline}

{title:Title}

{p2colset 5 19 21 2}{...}
{p2col :{hi:[ST] stgen} {hline 2}}Generate variables reflecting entire histories{p_end}
{p2colreset}{...}


{title:Syntax}

{p 8 14 2}{cmd:stgen} {dtype} {it:newvar} {cmd:=} {it:function}

{pstd}where {it:function} is

		{opth ever(exp)}
		{opth never(exp)}
		{opth always(exp)}
		{opth min(exp)}
		{opth max(exp)}
		{opth when(exp)}
		{opth when0(exp)}
		{opth count(exp)}
		{opth count0(exp)}
		{opth minage(exp)}
		{opth maxage(exp)}
		{opth avgage(exp)}
		{opt nfailures()}
		{opt ngaps()}
		{opt gaplen()}
		{opt hasgap()}

{pstd}
You must {cmd:stset} your data before using this command; see {helpb stset}.


{title:Description}

{pstd}
{cmd:stgen} provides a convenient way to generate new variables reflecting
entire histories{hline 2}variables you could create for yourself using
{cmd:generate} (and especially, {cmd:generate} with the {cmd:by}
{varlist}{it::} prefix), but that would require too much thought, and there
would be too much chance of making a mistake.

{pstd}
These functions are intended for use with multiple-record survival data but may
be used with single-record data.  With single-record data, each function 
reduces to a single {cmd:generate}, and {cmd:generate} would be a more natural
way to approach the problem.

{pstd}
{cmd:stgen} can be used with multiple-record or single- or multiple-failure st
data.

{pstd}
If you want to generate calculated values, such as the survivor function, etc.,
see {helpb sts}.


{title:Functions}

{pstd}
In the description of the functions below, note that time units refer to the
same units as {it:timevar} from {cmd:stset} {it:timevar}{cmd:,} {it:...}.
For instance, if {it:timevar} is in years{hline 2}years since 1960, years since
diagnosis, or whatever{hline 2}time units are years.

{pstd}
When we say variable X records a "time", we mean a variable that records when
something occurred in the same units and with the same base as {it:timevar}.
If {it:timevar} is a Stata date, "time" is corespondingly a Stata date.

{pstd}
t units, or analysis time units, refer to a variable in the units 
{it:timevar}/{opt scale()} from 
{cmd:stset} {it:timevar}{cmd:, scale(}{it:...}{cmd:)} {it:...}".  If you did 
not specify a {opt scale()}, t units are the same as time units.  Alternatively,
say that {it:timevar} is recorded as a Stata date and you specified 
{cmd:scale(365.25)}.  Then t units are years.  If you specified a nonconstant 
scale{hline 2}{cmd:scale(myvar)}, where {cmd:myvar} varies from subject to 
subject{hline 2}t units are different for every subject.

{pstd}
"An analysis time" refers to the time something occurred, recorded in the units
{cmd:(}{it:timevar}{cmd:-origin())/scale()}.  We speak about analysis time 
only in terms of the beginning and end of each time-span record.

{pstd}
Although in {it:Description} above we said that {cmd:stgen} creates variables
reflecting entire histories, {cmd:stgen} restricts itself to the {cmd:stset}
observations, so "entire history" means the entire history as it is currently
{cmd:stset}.  If you really want to use entire histories as recorded in the
data, type {cmd:streset, past} or {cmd:streset, past future} before using 
{cmd:stgen}.  Then type {cmd:streset} to reset to the original analysis sample.

{pstd}
The following functions are available:

{phang}
{opth ever(exp)} creates {newvar} containing 1 (true) if the expression is 
ever true (nonzero) and 0, otherwise.

{phang}
{opth never(exp)} is the reverse of {opt ever()}; it creates {newvar} 
containing 1 (true) if the expression is always false (0) and 0, otherwise.

{phang}
{opth always(exp)} creates {newvar} containing 1 (true) if the expression is 
always true (nonzero) and 0, otherwise.

{phang}
{opth min(exp)} and {opth max(exp)} create {newvar} containing the minimum or 
maximum nonmissing value of {it:exp} within {opt id()}.  {opt min()} and 
{opt max()} are often used with variables recording a time (see definition 
above), such as {cmd:min(visitdat)}.

{phang}
{opth when(exp)} and {opth when0(exp)} create {newvar} containing the time when
{it:exp} first became true within the previously {helpb stset} {opt id()}.  
Note that the result is in time, not t units; see definition above.

{pmore}
{opt when()} and {opt when0()} differ about when the {it:exp} became
true.  Records record time spans (time0,time1].  {opt when()} assumes the
expression became true at the end of the time span, time1.  {opt when0()}
assumes the expression became true at the beginning of the time span, time0.

{phang}
{opth count(exp)} and {opth count0(exp)} create {newvar} containing the number 
of occurrences when {it:exp} is true within {opt id()}.

{pmore}
{opt count()} and {opt count0()} differ in when they assume {it:exp} occurs.
{opt count()} assumes that {it:exp} corresponds to the end of the time-span
record.  Thus even if {it:exp} is true in this record, the count would remain
unchanged until the next record.

{pmore}
{opt count0()} assumes that {it:exp} corresponds to the beginning of the
time-span record.  Thus if {it:exp} is true in this record, the count is
immediately updated.

{phang}
{opth minage(exp)}, {opth maxage(exp)}, and {opth avgage(exp)} return the 
elapsed time, in time units since {it:exp} at the beginning, end, or middle of 
the record, respectively.  {it:exp} is expected to evaluate to a time in
time units.  {opt minage()}, {opt maxage()}, and {opt avgage()} would be 
appropriate for use with the result of {opt when()}, {opt when0()}, {opt min()},
and {opt max()}, for instance.

{pmore}
Also see {helpb stsplit}; {cmd:stsplit} will divide the time-span
records into new time-span records that record specified intervals of ages.

{phang}
{opt nfailures()} creates {newvar} containing the cumulative number of failures
for each subject as of the entry time for the observation.  {opt nfailures()} 
is intended for use with multiple-failure data; with single-failure data, 
{opt nfailures()} is always 0.

{phang}
{opt ngaps()} creates {newvar} containing the cumulative number of
gaps for each subject as of the entry time for the record.  Delayed entry
(an opening gap) is not considered a gap.

{phang}
{opt gaplen()} creates {newvar} containing the time on gap, measured in analysis
time units, for each subject as of the entry time for the observation.  Delayed
entry (an opening gap) is not considered a gap.

{phang}
{opt hasgap()} creates {newvar} containing uniformly 1 if the subject ever has 
a gap and 0, otherwise.  Delayed entry (an opening gap) is not considered a 
gap.


{title:Examples}

{phang}{cmd:. stset date, id(id) fail(code==122) entry(code==12)}

{phang}{cmd:. stgen everlow = ever(bp<100)}{p_end}
{phang}{cmd:. stgen neverlow = never(bp<100)}{p_end}
{phang}{cmd:. stgen low = always(bp<100)}

{phang}{cmd:. stgen nfail = nfailures()}

{phang}{cmd:. stgen gap = ngaps()}{p_end}
{phang}{cmd:. stgen gl  = gaplen()}{p_end}
{phang}{cmd:. stgen hg  = hasgap()}

{phang}{cmd:. streset, full past future}{p_end}
{phang}{cmd:. stgen fbdate = min(bdate)} {space 2} /* because missing on some records */{p_end}
{phang}{cmd:. streset}

{phang}{cmd:. streset, full past}{p_end}
{phang}{cmd:. stgen date1 = when(event==27)}{p_end}
{phang}{cmd:. stgen cnt27 = count(event==27)}{p_end}
{phang}{cmd:. stgen date2 = when(event==27 & cnt27==1)}


{title:Also see}

{psee}
 Manual:  {bf:[ST] stgen}

{psee}
Online:  {help st}, {helpb stci}, {helpb sts}, {helpb stset},
{helpb stvary}
{p_end}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -