We recently published revised estimates for national HIV prevalence among adult men and women from the Zambia 2007 Demographic and Health Surveys (DHS) using Heckman-type selection models to correct for potential selection bias due to non-participation in HIV testing during the DHS survey. Our goal here is to briefly describe the rationale for the use of Heckman-type selection models in this context and provide annotated Stata code that can be used for conducting this type of analysis in the Zambia 2007 DHS and, after adaptation, in other datasets.