📄 serset.hlp
字号:
subsequent commands, the current serset is not the one desired, you can set the
desired one using {cmd:serset set}, described below.
{title:serset create x_medians}
{pstd}
{cmd:serset create x_medians} creates a new serset based on the currently set
serset. The basic syntax is
{p 8 22 2}
{cmd:serset}
{cmd:create_xmedians}
{it:svn_y}
{it:svn_x}
[{it:svn_w}]
[{cmd:,}
...]
{pstd}
The new serset will contain cross medians. Put that aside. In the
{cmd:serset create_xmedians} command, you specify two or three variables to be
recorded in the current serset. The result is to create a new serset
containing two variables ({it:svn_y} and {it:svn_x}) and a different number of
observations. As with {cmd:serset create}, the result will also be to save in
{cmd:r()}:
{cmd:r(id)} the number assigned to the serset
{cmd:r(k)} the number of variables in the serset
{cmd:r(N)} the number of observations in the serset
{pstd}
The newly created serset will become the current serset.
{pstd}
In actual use, you might code
{cmd:serset create `yvar' `xvar' `zvar'}
{cmd:local base = r(id)}
...
{cmd:serset set `base'}
{cmd:serset create_xmedians `yvar' `xvar'}
{cmd:local cross = r(id)}
...
{pstd}
{cmd:serset create_xmedians} obtains data from the original serset and
calculates median values of {it:svn_y} and the median values of {it:svn_x}
for bands of {it:svn_x} values. The result is a new dataset of {it:n}
observations (one for each band) containing median y and median x values,
where the variables have the same name as the original variables.
These results are stored in the newly created serset. If a third variable is
specified, {it:svn_w}, the medians are calculated with weights.
{title:serset create_cspline}
{pstd}
{cmd:serset create_cspline} works in the same way as
{cmd:serset create_xmedians}: it takes one serset and creates another serset
from it, leaving the first unchanged. Thus as with all serset creation
commands, returned in {cmd:r()} is
{cmd:r(id)} the number assigned to the serset
{cmd:r(k)} the number of variables in the serset
{cmd:r(N)} the number of observations in the serset
{pstd}
and the newly created serset will become the current serset.
{pstd}
{cmd:serset create_cspline} performs cubic spline interpolation, and, in this
case, the new serset will contain the interpolated points. The original
serset should contain the knots through which the cubic spline is to pass.
{cmd:serset create_cspline} also has option {cmd:n(}{it:#}{cmd:)} that
specifies how many points are to be interpolated, so the resulting dataset
will have {it:N}+({it:N}-1)*{cmd:n()} observations, where {it:N} is the number
of observations in the original dataset. A typical use of
{cmd:serset create_cspline} would be
{cmd:serset create `yvar' `xvar'}
{cmd:local base = r(id)}
...
{cmd:serset set `base'}
{cmd:serset create_xmedians `yvar' `xvar'}
{cmd:local cross = r(id)}
...
{cmd:serset set `cross'}
{cmd:serset create_cspline `yvar' `xvar'}
...
{pstd}
In this example, the spline is placed through not the original data, but
cross medians of the data.
{title:serset set}
{pstd}
{cmd:serset set} is used to make a previously created serset the current
serset. You may omit the {cmd:set}. Typing
{cmd:serset 5}
{pstd}
is equivalent to typing
{cmd:serset set 5}
{pstd}
You would never actually know ahead of time the number of a serset that you
needed to code. Instead, when you created the serset, you would have recorded
the identity of the serset created, say, in a local macro, by typing
{cmd:local id = r(id)}
{pstd}
and then later, you would make that serset the current serset by coding
{cmd:serset set `id'}
{title:serset sort}
{pstd}
{cmd:serset sort} changes the order of the observations of the current
serset. For instance,
{cmd:serset create mpg weight length}
{cmd:local id = r(id)}
{cmd:serset sort weight mpg}
{pstd}
would place the observations of the serset in ascending order of variable
{cmd:weight} and, within equal values of {cmd:weight}, ascending order of
variable {cmd:mpg}.
{pstd}
If no variables are specified after {cmd:serset sort}, {cmd:serset sort}
does nothing. That is not considered an error.
{title:serset summarize}
{pstd}
{cmd:serset summarize} returns summary statistics about a variable in the
current serset. It does not display output or in any way change the
current serset.
{pstd}
Returned in {cmd:r()} is exactly what the {helpb summarize} command returns in
{cmd:r()}.
{title:serset use}
{pstd}
{cmd:serset use} loads a serset into memory. That is, it copies the current
serset into the current data. The serset is left unchanged.
{title:serset}
{pstd}
{cmd:serset} typed without arguments produces no output, but returns in
{cmd:r()} information about the current serset:
{cmd:r(id)} the number assigned to the current serset
{cmd:r(k)} the number of variables in the current serset
{cmd:r(N)} the number of observations in the current serset
{pstd}
If no serset is in use, {cmd:r(id)} is set to -1, and {cmd:r(k)} and {cmd:r(N)}
are left undefined; no error message is produced.
{title:serset reset_id}
{pstd}
{cmd:serset reset_id} is a rarely used command. Its syntax is
{p 8 22 2}
{cmd:serset}
{cmd:reset_id}
{it:#_s}
{pstd}
{cmd:serset reset_id} changes the ID of the current serset{hline 2}its
number{hline 2}to the number specified, if that is possible. If not, it
produces the error message "{err:series {it:#_s} in use}"; r(111).
{pstd}
Either way, the same serset continues to be the current serset (i.e., the
number of the current serset changes if the command is successful).
{title:serset drop}
{pstd}
{cmd:serset drop} eliminates (erases) the specified sersets from memory. For
instance,
{cmd:serset drop 5}
{pstd}
would eliminate serset 5, and
{cmd:serset drop 5/9}
{pstd}
would eliminate sersets 5, 6, 7, 8, and 9. Using {cmd:serset drop} to drop a
serset that does not exist is not an error; it does nothing.
{pstd}
Typing {cmd:serset drop _all} would drop all existing sersets.
{pstd}
Be careful not to drop sersets that are not yours: Stata's graphics system
creates and holds onto sersets frequently, and, if you drop one of its
sersets that are in use, the graph on the screen will eventually "fall apart",
and Stata will produce error messages (Stata will not crash). The graphics
system will itself drop sersets as it is through with them.
{pstd}
The {helpb discard} command also drops all existing sersets. This, however, is
safe because {cmd:discard} also closes any open graphs.
{title:serset clear}
{pstd}
{cmd:serset clear} is a synonym for {cmd:serset drop _all}.
{title:serset dir}
{pstd}
{cmd:serset dir} displays a description of all existing sersets.
{title:file sersetwrite and file sersetread}
{pstd}
{cmd:file} {cmd:sersetwrite} and {cmd:file} {cmd:sersetread} are extensions to
the {helpb file} command. These extensions write and read sersets into files.
The files may be opened {cmd:text} or {cmd:binary}, but, either way, what is
written into the file is in a binary format.
{pstd}
{cmd:file sersetwrite} writes the current serset. A code fragment might read
{cmd:serset create} ...
{cmd:local base = r(id)}
...
{cmd:tempname hdl}
{cmd:file open `hdl' using "`filename'", write} ...
...
{cmd:serset set `base'}
{cmd:file sersetwrite `hdl'}
...
{cmd:file close `hdl'}
{pstd}
{cmd:file sersetread} reads a serset from a file, creating a new serset in
memory. {cmd:file sersetread} returns in {cmd:r(id)} the serset ID of the
newly created serset. A code fragment might read
{cmd:tempname hdl}
{cmd:file open `hdl' using "`filename'", read} ...
...
{cmd:file sersetread `hdl'}
{cmd:local new = r(id)}
...
{cmd:file close `hdl'}
{pstd}
See {helpb file} for more information on the {cmd:file} command.
{title:Other things you can do with a serset}
{pstd}
The principal use of sersets is in graphics. Stata's lowest-level graphics
routines obtain the data they plot from sersets. They just know to do this.
{pstd}
Stata's mid-level graph routines all accept sersets as arguments or work
against the current serset; see the {bf:Stata Graphics Reference Manual}.
{title:Also see}
{psee}
Manual: {bf:[P] serset}
{psee}
Online: {helpb file}, {help gph files}, {helpb macro}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -