Stata Non-Survey Command for Descriptive Statistics Graphs
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.

 

histogram lbxtc, by(riagendr age), if (ridageyr >=20 & ridageyr <.) & ridstatr==2, normal

Use the histogram command to draw a histogram of the total cholesterol variable (lbxtc) for a select subpopulation (ages 20 and over). Use the normal option to overlay the histogram with normal density.
graph box lbxtc [pweight = wtmec4yr], medtype(line) over(riagendr) over(age),  if (ridageyr >=20 & ridageyr <.)& ridstatr==2  

Use the graph box command to box plot the total cholesterol data, by gender and age for those who are 20 years and older and have been both interviewed and examined (ridstatr=2). Use the [pweight=] option to account for the unequal probability of sampling and non-response.  In this example, the MEC weight for four years of data (wtmec4yr) is used. Use the medtype option to indicate how the median is indicated in the box.