Uploaded by Steven Penarrieta

STATA Notes

advertisement
Introduction to STATA (UNC):
https://www.cpc.unc.edu/research/tools/data_analysis/statatutorial
●
●
●
●
●
●
A simple example
○ Input: putting data into Stata
○ Generate: creating a new variable
○ List (or browse): viewing the contents of memory
○ Save: saving memory in a permanent Stata-format file
○ Log: Capturing the results of Stata commands for printing
○ Stata’s default actions
○ How data are stored in RAM
Using permanent Stata data files
○ Clear: Clearing Stata’s memory
○ Set memory: allowing enough space for the data
○ Use: copying the file into memory
○ Save,replace: saving changes
Describing the data
○ Describe: names of variables
○ Summarize: the mean, min, and max of variables
○ Codebook: more univariate statistics
○ Tabulate: frequencies and cross-tabulations data types and data storage
○ Data types and data storage
Groups and subsets of data
○ If: do command for a subset of observations
○ Sort: order observations by the values of a variable
○ By: do command for groups of observations (requires sort)
○ In: do command for a range of observations
○ Relational, logical, and arithmetic operators
○ Missing values
Changing the data
○ Replace: change the values of a variable
○ Recode: change the values of a variable
○ Rename: change a variable name
○ Label: labeling variables, values, and data files
○ Drop: drop one or more variables
○ Drop if: drop observations conditional on one or more variables
○ Edit: editing the data file directly
Data cleaning:
○ Do: storing and executing commands in do-files
○ #delimit: writing long commands in do-files
○ /**/: documenting your do-files
Download