stata_commands-3
stata_commands-3
1 insheetusing or file-import
alternatively one can import using the foll option
import excel filename.xlsx, sheet("mean") cellrange(a1:H10) firstrow
note : save op and data files separately
op can be saved in both smcl and txt format
2 use"path"
3 log using"path.smcl",append
4 log
using"path.smcl",replace
5 cmdlogusing" "
6*
7 sum
tabstat varname, stats(mean median kurtosis skewness)
8 display ""
sort
order var1 var2 var3
9 recode var(2000/min=1) (2001/5000=2)(5001/max=3)
10 corr
NOTE: the above t test commands are used if the statistic/parameter value is known
15 describe
16 tabulate varname varname
tabulate varname1 varname2, row
tabulate varname varname, column
tabulate varname varname, chi2
17 findit varname
18 bysort varname: sum varname2
19 if
20 codebook
21 generate
22 keep if varname== category
23 replace
eg: replace gender="1" if Gender=="Male"
replace age=25 in 50
24 ttest varname,by(category)
ttest var1=var2
syntax:
preserve
Savings=Income+Expenditure
restore
egen
31 egen varname2=rank(varname)
example: egen Inc_rank= rank(Income)
32 gen nawvar=oldvar
recode newvar()
meaning
to import excel file
ge(a1:H10) firstrow
descriptive statistics
displays only selected statistics as requested
displays strings and values of scalar expressions
to arrange the values of a variable in ascending order
rearranges the dataset in the particular order
to categorize variables into different variables or groups
to perform correalation between two or more variables
to do regression
to perform a twoway scatter with a line of fit
sheet name in the bracket and firstrow values acts as variable name
Pg 15 in Statistics with book
alternative to help
varname is the one according to which the output will be displayed
independent sample t tes where you check if the 2samples ccome from indentical pop with same mean
to check if the obsv diff between the two means is stat sig
statistical sig
lfitci
- generate works when the variable does not yet exist and will give an error if the variable already exists.
- replace works when the variable already exists, and will give an error if the variable does not yet exist.