-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathChapter2.do
More file actions
61 lines (41 loc) · 1.61 KB
/
Copy pathChapter2.do
File metadata and controls
61 lines (41 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
*******************************************************************************
*General Do-File Header*
clear all //clear memory
capture log close //close any log-files (if still running)
*version 15.0 //your current version, change this to your version (and remove asterisk)!
set more off //do not halt to show all output
*******************************************************************************
***Setting your current working directory***
cd "C:/Users/username/stata-course/"
/*You must replace this generic example with the path to the folder
where your files are saved*/
***Showing current working directory***
pwd
***Show all files in the current folder***
dir
ls //Alternative command
*use "filename.dta" //Open desired Stata file
***Alternative: absolute folder paths***
*use "C:\Users\username\stata-course\filename.dta"
***Entering data manually***
clear all //Start with a fresh memory
set obs 10 //10 observations (cases)
generate age = .
generate income = .
generate gender = .
edit //Edit data
browse //Inspect data
***Using preinstalled data***
sysuse auto, clear //Open preinstalled file
describe //Inspect data
***Exporting data to (open) file formats***
outsheet using "auto_export.csv" //CSV - Comma Separated Values
export excel using "etest.xls" //XLS - Microsoft Excel File Format
***Delimit and line breaks***
sysuse nlsw88, clear
#delimit ; //Tell Stata that all commands end with a semicolon from here on
count if age < 40 &
smsa == 1 &
wage > 20 &
grade >= 7; //Finally end your long command with the semicolon
#delimit cr //Restore standard settings