Useful Commands (short & random list)

To look for a word in any variable or variable label:

lookfor

Create a dummy per decile

xtile pct = income, n(10)
tab pct, gen(iq)

To quickly load part of a file, use

use xxx.dta if gender == 1, clear

Before saving a file, always compress it: it converts some types into lighter types (say doubles into integers) and can save a lot of space on the disk

compress
save file.dta, replace

A way to "compress" your files on-the-fly is by imposing the type of variables you create. For example, instead of typing

gen newvar = _n

you'd better type

gen int newvar = _n

because you know that the new variable will only contain integers. Other types are bytes, long, float and double. byte covers [-127,100], int covers [-32000,32000] (approx), and long is for non-integers, and covers negative few billions to few billions. In any case, Stata converts the type if needed, so it cannot hurt to try a lower type to save memory.

To get numerical values associated with label, use numlabel, add . It makes commands like tab more clear as it will show 1.female and 2.male so you know that to work on female you need to use ==1. At the very end of your code you can use numlabel, remove to remove the numeric values of the variables from the labels, such that you get clean tables to publish.

To run a program with pause type at the begining of do file

pause on

Then in the program you can type pause . The program will run until that point and pause. You can then explore variable etc... and restart the program by typing q (if you type BREAK, programs stops).

results matching ""

    No results matching ""