An introduction to Stata programming:
Gespeichert in:
1. Verfasser: | |
---|---|
Format: | Buch |
Sprache: | English |
Veröffentlicht: |
College Station, Tex.
Stata Press
2009
|
Ausgabe: | 1. ed. |
Schriftenreihe: | A Stata Press publication
|
Schlagworte: | |
Online-Zugang: | Inhaltsverzeichnis |
Beschreibung: | XIV, 362 S. graph. Darst. |
ISBN: | 1597180459 9781597180450 |
Internformat
MARC
LEADER | 00000nam a2200000 c 4500 | ||
---|---|---|---|
001 | BV035366915 | ||
003 | DE-604 | ||
005 | 20130917 | ||
007 | t | ||
008 | 090313s2009 d||| |||| 00||| eng d | ||
020 | |a 1597180459 |9 1-59718-045-9 | ||
020 | |a 9781597180450 |9 978-1-59718-045-0 | ||
035 | |a (OCoLC)316028338 | ||
035 | |a (DE-599)BSZ303431229 | ||
040 | |a DE-604 |b ger |e rakwb | ||
041 | 0 | |a eng | |
049 | |a DE-N2 |a DE-19 |a DE-945 |a DE-91 |a DE-703 |a DE-384 |a DE-473 |a DE-521 |a DE-188 |a DE-739 |a DE-29 |a DE-355 |a DE-20 | ||
050 | 0 | |a HA32 | |
082 | 0 | |a 519.5028553 | |
084 | |a QH 231 |0 (DE-625)141546: |2 rvk | ||
084 | |a ST 601 |0 (DE-625)143682: |2 rvk | ||
084 | |a DAT 307f |2 stub | ||
100 | 1 | |a Baum, Christopher F. |d 1951- |e Verfasser |0 (DE-588)128792612 |4 aut | |
245 | 1 | 0 | |a An introduction to Stata programming |c Christopher F. Baum |
250 | |a 1. ed. | ||
264 | 1 | |a College Station, Tex. |b Stata Press |c 2009 | |
300 | |a XIV, 362 S. |b graph. Darst. | ||
336 | |b txt |2 rdacontent | ||
337 | |b n |2 rdamedia | ||
338 | |b nc |2 rdacarrier | ||
490 | 0 | |a A Stata Press publication | |
630 | 0 | 4 | |a Stata |v Handbooks, manuals, etc |
650 | 4 | |a Sozialwissenschaften | |
650 | 4 | |a Statistik | |
650 | 4 | |a Social sciences |x Statistical methods |x Computer programs | |
650 | 4 | |a Statistics |x Computer programs |v Handbooks, manuals, etc | |
650 | 0 | 7 | |a Stata |0 (DE-588)4617285-3 |2 gnd |9 rswk-swf |
689 | 0 | 0 | |a Stata |0 (DE-588)4617285-3 |D s |
689 | 0 | |5 DE-604 | |
856 | 4 | 2 | |m HBZ Datenaustausch |q application/pdf |u http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=017170859&sequence=000002&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA |3 Inhaltsverzeichnis |
999 | |a oai:aleph.bib-bvb.de:BVB01-017170859 |
Datensatz im Suchindex
_version_ | 1804138693430083584 |
---|---|
adam_text | Titel: An introduction to Stata programming
Autor: Baum, Christopher F.
Jahr: 2009
Contents
List of tables xv
List of figures xvii
Preface xix
Acknowledgments xxi
Notation and typography xxiii
Why should you become a Stata programmer? 1
Do-file programming...................... 1
Ado-file programming ..................... 2
Mata programming for ado-files................ 2
1.1 Plan of the book............................. 3
1.2 Installing the necessary software .................... 3
Some elementary concepts and tools 5
2.1 Introduction................................ 5
2.1.1 What you should learn from this chapter........... 5
2.2 Navigational and organizational issues................. 5
2.2.1 The current working directory and profile.do......... 6
2.2.2 Locating important directories: sysdir and adopath..... 6
2.2.3 Organization of do-files, ado-files, and data files....... 7
2.3 Editing Stata do- and ado-files ..................... 8
2.4 Data types................................. 9
2.4.1 Storing data efficiently: The compress command ...... 11
2.4.2 Date and time handling .................... 11
2.4.3 Time-series operators...................... 12
2.5 Handling errors: The capture command................ 14
viii Contents
2.6 Protecting the data in memory: The preserve and restore commands 14
2.7 Getting your data into Stata ...................... 15
2.7.1 Inputting data from ASCII text files and spreadsheets ... 15
Handling text files ....................... 16
Free format versus fixed format................ 17
The insheet command ..................... 18
Accessing data stored in spreadsheets............. 20
Fixed-format data files..................... 20
2.7.2 Importing data from other package formats......... 25
2.8 Guidelines for Stata do-file programming style............. 26
2.8.1 Basic guidelines for do-file writers............... 27
2.8.2 Enhancing speed and efficiency................ 29
2.9 How to seek help for Stata programming................ 29
3 Do-file programming: Functions, macros, scalars, and matrices 33
3.1 Introduction................................ 33
3.1.1 What you should learn from this chapter........... 33
3.2 Some general programming details................... 34
3.2.1 The varlist............................ 35
3.2.2 The numlist........................... 35
3.2.3 The if exp and in range qualifiers............... 35
3.2.4 Missing data handling..................... 36
Recoding missing values: The mvdecode and mvencode
commands....................... 37
3.2.5 String-to-numeric conversion and vice versa......... 37
Numeric-to-string conversion.................. 38
Working with quoted strings.................. 39
3.3 Functions for the generate command.................. 40
3.3.1 Using if exp with indicator variables ............. 42
3.3.2 The cond() function ...................... 44
3.3.3 Recoding discrete and continuous variables.......... 45
Contents ix
3.4 Functions for the eðen command.................... 47
Official egen functions..................... 47
egen functions from the user community........... 49
3.5 Computation for by-groups....................... 50
3.5.1 Observation numbering: _n and _N.............. 50
3.6 Local macros............................... 53
3.7 Global macros............................... 56
3.8 Extended macro functions and macro list functions.......... 56
3.8.1 System parameters, settings, and constants: creturn .... 57
3.9 Scalars................................... 58
3.10 Matrices.................................. 60
4 Cookbook: Do-file programming I 63
4.1 Tabulating a logical condition across a set of variables........ 63
4.2 Computing summary statistics over groups .............. 65
4.3 Computing the extreme values of a sequence.............. 66
4.4 Computing the length of spells..................... 67
4.5 Summarizing group characteristics over observations......... 71
4.6 Using global macros to set up your environment............ 73
4.7 List manipulation with extended macro functions........... 74
4.8 Using creturn values to document your work.............. 76
5 Do-file programming: Validation, results, and data management 79
5.1 Introduction................................ 79
5.1.1 What you should learn from this chapter........... 79
5.2 Data validation: The assert, count, and duplicates commands .... 79
5.3 Reusing computed results: The return and ereturn commands .... 86
5.3.1 The ereturn list command................... 90
5.4 Storing, saving, and using estimated results.............. 93
5.4.1 Generating publication-quality tables from stored estimates 98
5.5 Reorganizing datasets with the reshape command........... 99
5.6 Combining datasets............................ 105
x Contents
5.7 Combining datasets with the append command............ 107
5.8 Combining datasets with the merge command............. 108
5.8.1 The dangers of many-to-many merges............. 110
5.9 Other data-management commands................... Ill
5.9.1 The fiilin command....................... 112
5.9.2 The cross command....................... 112
5.9.3 The stack command ...................... 112
5.9.4 The separate command..................... 114
5.9.5 The joinby command...................... 115
5.9.6 The xpose command...................... 115
6 Cookbook: Do-file programming II 117
6.1 Efficiently defining group characteristics and subsets......... 117
6.1.1 Using a complicated criterion to select a subset of observations 118
6.2 Applying reshape repeatedly....................... 119
6.3 Handling time-series data effectively.................. 123
6.4 reshape to perform rowwise computation................ 126
6.5 Adding computed statistics to presentation-quality tables...... 128
6.5.1 Presenting marginal effects rather than coefficients..... 130
6.6 Generating time-series data at a lower frequency........... 132
7 Do-file programming: Prefixes, loops, and lists 139
7.1 Introduction................................ 139
7.1.1 What you should learn from this chapter........... 139
7.2 Prefix commands............................. 139
7.2.1 The by prefix........................... 140
7.2.2 The xi prefix........................... 142
7.2.3 The statsby prefix........................ 145
7.2.4 The rolling prefix........................ 146
7.2.5 The simulate and permute prefix............... 148
7.2.6 The bootstrap and jackknife prefixes............. 151
7.2.7 Other prefix commands..................... 153
Contents xi
7.3 The forvalues and foreach commands.................. 154
8 Cookbook: Do-file programming III 161
8.1 Handling parallel lists.......................... 161
8.2 Calculating moving-window summary statistics............ 162
8.2.1 Producing summary statistics with rolling and merge .... 164
8.2.2 Calculating moving-window correlations........... 165
8.3 Computing monthly statistics from daily data............. 166
8.4 Requiring at least n observations per panel unit............ 167
8.5 Counting the number of distinct values per individual........ 169
9 Do-file programming: Other topics 171
9.1 Introduction................................ 171
9.1.1 What you should learn from this chapter........... 171
9.2 Storing results in Stata matrices .................... 171
9.3 The post and postfile commands.................... 175
9.4 Output: The outsheet, outfile, and file commands........... 177
9.5 Automating estimation output ..................... 181
9.6 Automating graphics........................... 184
9.7 Characteristics.............................. 188
10 Cookbook: Do-file programming IV 191
10.1 Computing firm-level correlations with multiple indices........ 191
10.2 Computing marginal effects for graphical presentation........ 194
10.3 Automating the production of LM£X tables.............. 197
10.4 Tabulating downloads from the Statistical Software Components
archive................................... 202
10.5 Extracting data from graph files sersets................ 204
10.6 Constructing continuous price and returns series........... 209
11 Ado-file programming 215
11.1 Introduction................................ 215
11.1.1 What you should learn from this chapter........... 216
11.2 The structure of a Stata program.................... 216
xii Contents
11.3 The program statement ......................... 217
11.4 The syntax and return statements ................... 218
11.5 Implementing program options..................... 221
11.6 Including a subset of observations.................... 222
11.7 Generalizing the command to handle multiple variables........ 224
11.8 Making commands byable........................ 226
Program properties....................... 228
11.9 Documenting your program....................... 228
11.10 egen function programs ......................... 231
11.11 Writing an e-class program....................... 232
11.11.1 Defining subprograms...................... 234
11.12 Certifying your program......................... 234
11.13 Programs for ml, nl, nlsur, simulate, bootstrap, and jackknife .... 236
Writing an ml-based command ................ 237
11.13.1 Programs for the nl and nlsur commands........... 240
11.13.2 Programs for the simulate, bootstrap, and jackknife prefixes 242
11.14 Guidelines for Stata ado-file programming style............ 244
11.14.1 Presentation........................... 244
11.14.2 Helpful Stata features ..................... 245
11.14.3 Respect for datasets ...................... 246
11.14.4 Speed and efficiency ...................... 246
11.14.5 Reminders............................ 247
11.14.6 Style in the large........................ 247
11.14.7 Use the best tools........................ 248
12 Cookbook: Ado-file programming 249
12.1 Retrieving results from rolling: ..................... 249
12.2 Generalization of egen function pct9010() to support all pairs of
quantiles.................................. 252
12.3 Constructing a certification script.................... 254
Contents xiii
12.4 Using the ml command to estimate means and variances....... 259
12.4.1 Applying equality constraints in ml estimation........ 261
12.5 Applying inequality constraints in ml estimation........... 262
12.6 Generating a dataset containing the single longest spell........ 267
13 Mata functions for ado-file programming 271
13.1 Mata: First principles.......................... 271
13.1.1 What you should learn from this chapter........... 272
13.2 Mata fundamentals............................ 272
13.2.1 Operators............................ 272
13.2.2 Relational and logical operators................ 274
13.2.3 Subscripts............................ 274
13.2.4 Populating matrix elements.................. 275
13.2.5 Mata loop commands...................... 276
13.2.6 Conditional statements..................... 278
13.3 Function components........................... 279
13.3.1 Arguments............................ 279
13.3.2 Variables............................. 280
13.3.3 Saved results .......................... 280
13.4 Calling Mata functions.......................... 281
13.5 Mata s st_ interface functions...................... 283
13.5.1 Data access........................... 283
13.5.2 Access to locals, globals, scalars, and matrices........ 285
13.5.3 Access to Stata variables attributes ............. 286
13.6 Example: st_ interface function usage.................. 286
13.7 Example: Matrix operations....................... 288
13.7.1 Extending the command.................... 293
13.8 Creating arrays of temporary objects with pointers.......... 295
13.9 Structures................................. 299
13.10 Additional Mata features ........................ 302
13.10.1 Macros in Mata functions................... 302
xiv Contents
13.10.2 Compiling Mata functions................... 303
13.10.3 Building and maintaining an object library.......... 304
13.10.4 A useful collection of Mata routines.............. 305
14 Cookbook: Mata function programming 307
14.1 Reversing the rows or columns of a Stata matrix........... 307
14.2 Shuffling the elements of a string variable............... 311
14.3 Firm-level correlations with multiple indices with Mata........ 312
14.4 Passing a function to a Mata function................. 316
14.5 Using subviews in Mata......................... 319
14.6 Storing and retrieving country-level data with Mata structures . . . 321
14.7 Locating nearest neighbors with Mata................. 327
14.8 Computing the seemingly unrelated regression estimator....... 331
14.9 A GMM-CUE estimator using Mata s optimize() functions...... 337
References 349
Author index 353
Subject index 355
|
any_adam_object | 1 |
author | Baum, Christopher F. 1951- |
author_GND | (DE-588)128792612 |
author_facet | Baum, Christopher F. 1951- |
author_role | aut |
author_sort | Baum, Christopher F. 1951- |
author_variant | c f b cf cfb |
building | Verbundindex |
bvnumber | BV035366915 |
callnumber-first | H - Social Science |
callnumber-label | HA32 |
callnumber-raw | HA32 |
callnumber-search | HA32 |
callnumber-sort | HA 232 |
callnumber-subject | HA - Statistics |
classification_rvk | QH 231 ST 601 |
classification_tum | DAT 307f |
ctrlnum | (OCoLC)316028338 (DE-599)BSZ303431229 |
dewey-full | 519.5028553 |
dewey-hundreds | 500 - Natural sciences and mathematics |
dewey-ones | 519 - Probabilities and applied mathematics |
dewey-raw | 519.5028553 |
dewey-search | 519.5028553 |
dewey-sort | 3519.5028553 |
dewey-tens | 510 - Mathematics |
discipline | Informatik Mathematik Wirtschaftswissenschaften |
edition | 1. ed. |
format | Book |
fullrecord | <?xml version="1.0" encoding="UTF-8"?><collection xmlns="http://www.loc.gov/MARC21/slim"><record><leader>01756nam a2200457 c 4500</leader><controlfield tag="001">BV035366915</controlfield><controlfield tag="003">DE-604</controlfield><controlfield tag="005">20130917 </controlfield><controlfield tag="007">t</controlfield><controlfield tag="008">090313s2009 d||| |||| 00||| eng d</controlfield><datafield tag="020" ind1=" " ind2=" "><subfield code="a">1597180459</subfield><subfield code="9">1-59718-045-9</subfield></datafield><datafield tag="020" ind1=" " ind2=" "><subfield code="a">9781597180450</subfield><subfield code="9">978-1-59718-045-0</subfield></datafield><datafield tag="035" ind1=" " ind2=" "><subfield code="a">(OCoLC)316028338</subfield></datafield><datafield tag="035" ind1=" " ind2=" "><subfield code="a">(DE-599)BSZ303431229</subfield></datafield><datafield tag="040" ind1=" " ind2=" "><subfield code="a">DE-604</subfield><subfield code="b">ger</subfield><subfield code="e">rakwb</subfield></datafield><datafield tag="041" ind1="0" ind2=" "><subfield code="a">eng</subfield></datafield><datafield tag="049" ind1=" " ind2=" "><subfield code="a">DE-N2</subfield><subfield code="a">DE-19</subfield><subfield code="a">DE-945</subfield><subfield code="a">DE-91</subfield><subfield code="a">DE-703</subfield><subfield code="a">DE-384</subfield><subfield code="a">DE-473</subfield><subfield code="a">DE-521</subfield><subfield code="a">DE-188</subfield><subfield code="a">DE-739</subfield><subfield code="a">DE-29</subfield><subfield code="a">DE-355</subfield><subfield code="a">DE-20</subfield></datafield><datafield tag="050" ind1=" " ind2="0"><subfield code="a">HA32</subfield></datafield><datafield tag="082" ind1="0" ind2=" "><subfield code="a">519.5028553</subfield></datafield><datafield tag="084" ind1=" " ind2=" "><subfield code="a">QH 231</subfield><subfield code="0">(DE-625)141546:</subfield><subfield code="2">rvk</subfield></datafield><datafield tag="084" ind1=" " ind2=" "><subfield code="a">ST 601</subfield><subfield code="0">(DE-625)143682:</subfield><subfield code="2">rvk</subfield></datafield><datafield tag="084" ind1=" " ind2=" "><subfield code="a">DAT 307f</subfield><subfield code="2">stub</subfield></datafield><datafield tag="100" ind1="1" ind2=" "><subfield code="a">Baum, Christopher F.</subfield><subfield code="d">1951-</subfield><subfield code="e">Verfasser</subfield><subfield code="0">(DE-588)128792612</subfield><subfield code="4">aut</subfield></datafield><datafield tag="245" ind1="1" ind2="0"><subfield code="a">An introduction to Stata programming</subfield><subfield code="c">Christopher F. Baum</subfield></datafield><datafield tag="250" ind1=" " ind2=" "><subfield code="a">1. ed.</subfield></datafield><datafield tag="264" ind1=" " ind2="1"><subfield code="a">College Station, Tex.</subfield><subfield code="b">Stata Press</subfield><subfield code="c">2009</subfield></datafield><datafield tag="300" ind1=" " ind2=" "><subfield code="a">XIV, 362 S.</subfield><subfield code="b">graph. Darst.</subfield></datafield><datafield tag="336" ind1=" " ind2=" "><subfield code="b">txt</subfield><subfield code="2">rdacontent</subfield></datafield><datafield tag="337" ind1=" " ind2=" "><subfield code="b">n</subfield><subfield code="2">rdamedia</subfield></datafield><datafield tag="338" ind1=" " ind2=" "><subfield code="b">nc</subfield><subfield code="2">rdacarrier</subfield></datafield><datafield tag="490" ind1="0" ind2=" "><subfield code="a">A Stata Press publication</subfield></datafield><datafield tag="630" ind1="0" ind2="4"><subfield code="a">Stata</subfield><subfield code="v">Handbooks, manuals, etc</subfield></datafield><datafield tag="650" ind1=" " ind2="4"><subfield code="a">Sozialwissenschaften</subfield></datafield><datafield tag="650" ind1=" " ind2="4"><subfield code="a">Statistik</subfield></datafield><datafield tag="650" ind1=" " ind2="4"><subfield code="a">Social sciences</subfield><subfield code="x">Statistical methods</subfield><subfield code="x">Computer programs</subfield></datafield><datafield tag="650" ind1=" " ind2="4"><subfield code="a">Statistics</subfield><subfield code="x">Computer programs</subfield><subfield code="v">Handbooks, manuals, etc</subfield></datafield><datafield tag="650" ind1="0" ind2="7"><subfield code="a">Stata</subfield><subfield code="0">(DE-588)4617285-3</subfield><subfield code="2">gnd</subfield><subfield code="9">rswk-swf</subfield></datafield><datafield tag="689" ind1="0" ind2="0"><subfield code="a">Stata</subfield><subfield code="0">(DE-588)4617285-3</subfield><subfield code="D">s</subfield></datafield><datafield tag="689" ind1="0" ind2=" "><subfield code="5">DE-604</subfield></datafield><datafield tag="856" ind1="4" ind2="2"><subfield code="m">HBZ Datenaustausch</subfield><subfield code="q">application/pdf</subfield><subfield code="u">http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=017170859&sequence=000002&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA</subfield><subfield code="3">Inhaltsverzeichnis</subfield></datafield><datafield tag="999" ind1=" " ind2=" "><subfield code="a">oai:aleph.bib-bvb.de:BVB01-017170859</subfield></datafield></record></collection> |
id | DE-604.BV035366915 |
illustrated | Illustrated |
indexdate | 2024-07-09T21:32:15Z |
institution | BVB |
isbn | 1597180459 9781597180450 |
language | English |
oai_aleph_id | oai:aleph.bib-bvb.de:BVB01-017170859 |
oclc_num | 316028338 |
open_access_boolean | |
owner | DE-N2 DE-19 DE-BY-UBM DE-945 DE-91 DE-BY-TUM DE-703 DE-384 DE-473 DE-BY-UBG DE-521 DE-188 DE-739 DE-29 DE-355 DE-BY-UBR DE-20 |
owner_facet | DE-N2 DE-19 DE-BY-UBM DE-945 DE-91 DE-BY-TUM DE-703 DE-384 DE-473 DE-BY-UBG DE-521 DE-188 DE-739 DE-29 DE-355 DE-BY-UBR DE-20 |
physical | XIV, 362 S. graph. Darst. |
publishDate | 2009 |
publishDateSearch | 2009 |
publishDateSort | 2009 |
publisher | Stata Press |
record_format | marc |
series2 | A Stata Press publication |
spelling | Baum, Christopher F. 1951- Verfasser (DE-588)128792612 aut An introduction to Stata programming Christopher F. Baum 1. ed. College Station, Tex. Stata Press 2009 XIV, 362 S. graph. Darst. txt rdacontent n rdamedia nc rdacarrier A Stata Press publication Stata Handbooks, manuals, etc Sozialwissenschaften Statistik Social sciences Statistical methods Computer programs Statistics Computer programs Handbooks, manuals, etc Stata (DE-588)4617285-3 gnd rswk-swf Stata (DE-588)4617285-3 s DE-604 HBZ Datenaustausch application/pdf http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=017170859&sequence=000002&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA Inhaltsverzeichnis |
spellingShingle | Baum, Christopher F. 1951- An introduction to Stata programming Stata Handbooks, manuals, etc Sozialwissenschaften Statistik Social sciences Statistical methods Computer programs Statistics Computer programs Handbooks, manuals, etc Stata (DE-588)4617285-3 gnd |
subject_GND | (DE-588)4617285-3 |
title | An introduction to Stata programming |
title_auth | An introduction to Stata programming |
title_exact_search | An introduction to Stata programming |
title_full | An introduction to Stata programming Christopher F. Baum |
title_fullStr | An introduction to Stata programming Christopher F. Baum |
title_full_unstemmed | An introduction to Stata programming Christopher F. Baum |
title_short | An introduction to Stata programming |
title_sort | an introduction to stata programming |
topic | Stata Handbooks, manuals, etc Sozialwissenschaften Statistik Social sciences Statistical methods Computer programs Statistics Computer programs Handbooks, manuals, etc Stata (DE-588)4617285-3 gnd |
topic_facet | Stata Handbooks, manuals, etc Sozialwissenschaften Statistik Social sciences Statistical methods Computer programs Statistics Computer programs Handbooks, manuals, etc Stata |
url | http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=017170859&sequence=000002&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA |
work_keys_str_mv | AT baumchristopherf anintroductiontostataprogramming |