Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use NHANES 3 .dat files in Stata?

    Hello,

    I am interested in NHANES 3 data.

    At the Homepage (https://wwwn.cdc.gov/nchs/nhanes/nha...iles.aspx#core), I can download adult.dat file by right clicking and using "save link as".
    However, I cannot use this file in Stata yet. The file seems to be filled with ASCII codes..

    What is the best way to use .dat files of NHANES 3 in Stata? (Other dataset as .xpt files can be used in Stata.)

    Thanks.

  • #2
    The file is a fixed-format text file. That is, each observation is a long string of characters, and each variable occupies the same position in each observation. To import this into Stata you will need to use the -infix- command. You will also need to know which variables are in which columns--you will find that in the documentation file that is linked to the right of the data file itself. That documentation also contains information that you can use to attach value labels and variable labels to the Stata data set. Also helpful, by the way, is the linked SAS code, also to the right of the data file link. Although you can't run SAS code in Stata, part of the SAS code can, with fairly simple and quick editing, be turned into a data dictionary file for Stata to use in the importation.

    You will also need to carefully study the first approximately 30 pages of the documentation file to understand the sampling scheme that was used. That information is crucial so that you can properly -svyset- the data so as to do valid analyses.

    For details about the -infix- command read -help infix-. Examples and other helpful information will also be found at the link to the PDF documentation provided there.

    Comment

    Working...
    X