[b]我在stata中的help找到了。
附给大家。
Reshape高级句法
Description of advanced syntax
The advanced syntax is simply a different way of specifying the reshape command, and it has one seldom-used feature that provides extra control. Rather than typing one reshape command to describe the data and perform the conversion, such as
. reshape long inc, i(id) j(year)
you type a sequence of reshape commands. The initial commands describe the data, and the last command performs the conversion:
. reshape i id
. reshape j year
. reshape xij inc
. reshape long
reshape i corresponds to i() in the basic syntax.
reshape j corresponds to j() in the basic syntax.
reshape xij corresponds to the variables specified in the basic syntax. reshape xij also accepts the atwl() option for use when @ characters are specified in the fvarnames. atwl stands for at-when-long. When you specify names such as inc@r or ue@, in the long form the names become incr and ue, and the @ character is ignored. atwl() allows you to change @ into whatever you specify. For example, if you specify atwl(X), the long-form names become incXr and ueX.
There is also one more specification, which has no counterpart in the basic syntax:
. reshape xi varlist
In the basic syntax, Stata assumes that all unspecified variables are constant within i. The advanced
syntax works the same way, unless you specify the reshape xi command, which names the constant-
within-i variables. If you specify reshape xi, any variables that you do not explicitly specify are
dropped from the data during the conversion.
As a practical matter, you should explicitly drop the unwanted variables before conversion. For
instance, suppose that the data have variables inc80, inc81, inc82, sex, age, and age2 and that
you no longer want the age2 variable. You could specify
. reshape xi sex age
or
. drop age2
and leave reshape xi unspecified.
reshape xi does have one minor advantage. It saves reshape the work of determining which variables are unspecified. This saves a relatively small amount of computer time.
Another advanced-syntax feature is reshape query, which is equivalent to typing reshape byitself. reshape query reports which reshape parameters have been defined. reshape i, reshape j, reshape xij, and reshape xi specifications may be given in any order and may be repeated to change or correct what has been specified.
Finally, reshape clear clears the definitions. reshape definitions are stored with the dataset when you save it. reshape clear allows you to erase these definitions.
The basic syntax of reshape is implemented in terms of the advanced syntax, so you can mix basic and advanced syntaxes.
|