Cheat Sheet: With Stata 15
Cheat Sheet: With Stata 15
with Stata 15 Cheat Sheet All Stata commands have the same format (syntax):
For more info see Stata’s reference manual (stata.com) [E\£varlist1:]£FRPPDQG£ [varlist2] [=exp] [LI£H[S] [LQ£range] [weight] [XVLQJ£filename] [,options]
apply the function: what are column to save output as condition: only apply to apply pull data from a file special options
Useful Shortcuts command across you going to do apply a new variable apply the function specific rows weights (if not loaded) for command
each unique to varlists? command to if something is true
combination of
F2 keyboard buttons Ctrl + 9 variables in In this example, we want a detailed summary
varlist1 bysort rep78 : summarize price if foreign == 0 & price <= 9000, detail with stats like kurtosis, plus mean and median
describe data open a new .do file
Ctrl + 8 Ctrl + D
To find out more about any command – like what options it takes – type KHOS£command
open the data editor highlight text in .do file,
clear then ctrl + d executes it
delete data in memory in the command line Basic Data Operations Change Data Types
$ঔ&এঁ3এঐঔ Arithmetic Logic == tests if something is equal Stata has 6 data types, and data can also be missing:
= assigns a value to a variable no data true/false words numbers
add (numbers) & and == equal < less than missing byte string int long float double
PgUp PgDn scroll through previous commands + combine (strings)
! or ~ not != not <= less than or equal to To convert between numbers & strings:
î subtract or > greater than gen foreignString = string(foreign) "1"
Tab autocompletes variable name after typing part | or ~= equal 1 tostring foreign, gen(foreignString) "1"
>= greater or equal to
cls clear the console (where results are displayed) * multiply if foreign != 1 & price >= 10000 if foreign != 1 | price >= 10000
decode foreign , gen(foreignString) "foreign"