SAS tabstat command for displaying selected statistics

Statements Explanation

use
"C:\Stata\tutorial\analysis_data.dta",
clear

Use the use command to load the Stata-format dataset. Use the clear option to replace any data in memory.

by riagendr: tabstat lbxtc [aweight=wtmec4yr], by(age) statistics(mean p25 median p75), if (ridageyr >=20 & ridageyr <.) & ridstatr==2

Use the by prefix and the tabstat command along with the by ( ) option and statistics ( ) option to generate by gender (riagendr) and by (age), selected summary statistics (mean, 25th percentile, median, 75th percentile) for the total cholesterol variable (lbxtc), for those who are 20 years and older and have been both interviewed and examined (ridstatr=2). Use the [aweight=] option to account for data inversely proportional to the variance of an observation. In this example, the MEC weight for four years of data (wtmec4yr) is used.