Minot
Using Stata for Survey Analysis
Page 14
bysort prefix
This is not an independent command but rather a “prefix” goes before another command and asks
Stata to repeat the command for each value of a variable. There is no equivalent command in SPSS.
The general syntax is:
bysort varlist:
command
where “varlist” is one or more variables (usually just one) and “command” is the Stata command to be
repeated. Some
examples of the bysort prefix are:
bysort stratum: sum hh_size
for each stratum, give statistics on household size
bysort stratum: tab b21_q1
for each stratum, give the frequency table of sex of head
Example 6 shows the output of a bysort command. It produces two tables,
one for urban households
(stratum=u) and one for rural households (stratum=r). The results indicate that female-headed
household account for 14% of the households in the urban portion of the BLSS sample and 36% of
the rural portion.
Example 6. Using the “bysort” prefix
save
This command saves the data in memory. It is equivalent to “save outfile” in SPSS. The syntax is:
Do'stlaringiz bilan baham: