Using Stata for Survey Data Analysis


Example 15. Using “tabstat” to create tables


Download 1.39 Mb.
Pdf ko'rish
bet39/61
Sana08.03.2023
Hajmi1.39 Mb.
#1252470
1   ...   35   36   37   38   39   40   41   42   ...   61
Bog'liq
2009 Usingstataforsurveydataanalysis (1)

Example 15. Using “tabstat” to create tables 
table 
This command can creates many types of tables. It is probably the most flexible and useful of all the 
table commands in Stata. The syntax is: 
table rowvar colvar [if exp] [in range], c(clist) [row col]
where 
rowvar
is the categorical row variable 
colvar
is the categorical column variable 
clist 
is a list of statistic and variables 
row 
is an option to include a summary row 
col 
is an option to include a summary column 
Some useful facts about this command: 
The default statistic is the frequency. 
Optional statistics are mean, sd, sum, rawsum (unweighted), count, max, min, median, and p
(nth percentile).
The c( ) is short for contents of each cell.
Like tab, it can be used to create one- and two-way frequency tables, but table cannot do 
percentages 
Like tab…sum, it can be used to calculate basic stats for each value of a categorical variable 


Using Stata for Survey Data Analysis 
 
Minot 
 
Page 35
Its advantagehead over tab…sum is that it can do more statistics and it can take more than 
one continious variable 
Like tabstat, it can be used to calculate advanced stats for each value of a categorical variable 
Its advantage over tabstat is that it can use do two- and three-way tables, but its disadvantage 
is that it has fewer statistics. 
It is similar to “table” in SPSS, but much easier to learn. On the other hand, it is less flexible 
than the “table” command in SPSS.
Here are some examples: 
. table region, row 
table of number of households in each 
region, with a total row 
. table region, c(mean pcexpend)
table of average pcexpend by region 
. table region, c(mean yield sd yield median yield) table of yield statistics by region 
. table region, c(mean yield) format(%9.2f)
table of average yields by region with format 
. table region sexhead, c(mean yield) 
table of average yield by region and sex
. table region c(mean pcexpend mean yield)
table of avg yield & pcexpend by region 
The box below shows the output of three table commands. The first table shows the mean household 
size in each region and in each stratum (urban and rural). The option format(%4.1fmeans fixed 
format with 4 digits and one to the right of the decimal point. The second table shows the mean per 
capita expenditure for each region and for male and female-headed households. The option 
format(%7.0fc) means that seven digits should be displayed, but none to the right of the decimal 
period, in fixed comma format. The third table shows the mean household size and per capita 
expenditure in each region. 

Download 1.39 Mb.

Do'stlaringiz bilan baham:
1   ...   35   36   37   38   39   40   41   42   ...   61




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling