Read ASCII (text) data created by a spreadsheetĭescribe contents of data in memory or on disk Graphs are not saved in log files Use “saving” option of graph commands replace, append log close Output choices: *.log file - ASCII file *.smcl file - nicer format for viewing and printing in Stata 35 Basic Commands, cont. Work in do-files and log your sessions! keep age race sex ///The remainder of this line will be ignored, including return first_name height weight last_name /*This line continuation of the last line 34 Saving output Use mydata.dta /* These words will be ignored */ do myjob.do //The remainder of this line will be ignored. Comments - example *SAMPLE EXCERPT OF STATA DO-FILE *This line will be ignored by Stata. Comments Lines beginning with * will be ignored Words between /* and */ will be ignored (spanning multiple lines ok) Words between // and end of line will be ignored Words between /// and beginning of next line will be ignored (one way to spread command over two lines) 33 Do-files > Comments Example 1: #delimit #delimit keep firstname lastname birth death age weight height #delimit cr Example 2: /* */ keep firstname lastname birth /* */ age weight height Example 3: /// keep firstname lastname birth /// age weight height 32 Do-files > Comments Commands requiring multiple lines delimit This command tells Stata to read semi-colons as the end-of-line character instead of the carriage return Comment out the carriage return with /* at the end of line and */ at the beginning of next Comment out the carriage return with /// 31 Do-files > End of line Character Header Include in do-files – name, project, project location, date, purpose, inputs, outputs, special instructions Version Control include version at top of do-file Why? Replace weightlt200 = 0 if weight >= 200 & weight Header, Version Control replace weightlt200 = 0 if weight >= 200 INSTEAD. ] Example 7 (webuse union) Generally [= Result: Detailed summaries of variable age, separated over different values of black, includes only obs with year >= 80 19 Stata Syntax, cont. bysort black: summarize age if year >= 80, detail ] Example 6 (webuse union) Stata Command: Result: Summarizes age separately for different values of black, including only obs for which year >= 80 18 Stata Syntax, cont. ] Example 5 (webuse union) Stata Command: Result: Summarizes variable age, includes only first 100 obs and only obs with year >= 80 17 Stata Syntax, cont. ] Example 4 (webuse union) Stata Command: Result: Summarizes age, includes only observations with year >= 80 16 Stata Syntax, cont. ] Example 3 (webuse union) Stata Command: Result: Summarizes variable age 15 Stata Syntax, cont. ] Example 2 (webuse union) Stata command: Result: Summarizes all dataset variables (_all) 14 Stata Syntax, cont. ] Example 1 (webuse union) Stata Command. ] Brackets = optional portions Italics = user specified 13 Stata Syntax, cont. compress - saves data more efficiently reshape – long/wide sort/ gsort order rename 12 Stata Syntax recode replace 10 Basic Commands, cont.
(one-way tabulation of variables) tab2 varlist (two-way tabulations of variables) 9 Basic Commands, cont. Handout 1 (green) Reading raw data insheet, input, infix, infile Using/saving a Stata dataset use, Windows: Programs > Stata8 Command Window: enter commands Results Window Other: review, variables, do-editor Unix: Interactive Stata commands and results show in same window Batch Stata nice +10 stata –b do See ATS website for transferring files between SAS, Stata, and SPSS
Insheet stata windows#
DBMS/Copy for Unix (without xwindows) From Unix prompt dbmsnoxĪre “pseudo” extensions spsswin = SPSS for Windows Stata7 = Stata 7 sas7sun = SAS for Unix v7 ssdsun = SAS for Unix v6 Example – windows spss to stata7
Insheet stata manual#
(replace st with local Stat/Transfer invocation) See manual for more info and options Check results! Converting Data between Statistical Packages Stata – Basic Commands Command Syntax Abbreviations Missing Values Combining Data Using do-files Getting Help Updating Stata 2Ĭonverting Data – Windows Stat/Transfer SAS, Stata, S-Plus, SPSS, Excel, and more Windows interface Enter “in” data and “out” data Enter info on other tabs as necessary Check results!Ĭonverting Data – Unix Stat/Transfer From within stat-transfer invoke stat/transfer (specific to Unix machine) at stat/transfer prompt, enter:ĭatfile1.ext1 = original file, datfile2.ext2 = new file From Unix prompt CCPR Computing Services Workshop 2: Stata October 20, 2004