Using Stata for Survey Data Analysis


Download 1.39 Mb.
Pdf ko'rish
bet58/61
Sana08.03.2023
Hajmi1.39 Mb.
#1252470
1   ...   53   54   55   56   57   58   59   60   61
Bog'liq
2009 Usingstataforsurveydataanalysis (1)

Minot
 
 
 
 
 
Using Stata for Survey Analysis 
Page 54 
 

Example 25. Using “svyset” to adjust regression estimates for sampling design 


Using Stata for Survey Data Analysis 
 
Minot 
 
Page 55
SECTION 11: INTRODUCTION TO PROGRAMMING WITH STATA
This section provides a very quick introduction to the topic of programming with Stata. We touch on 
three topics: 
creating and using macros 
creating and using loops 
matrix algebra 
The purpose here is not to provide a comprehensive description of how to program with Stata, but 
rather to give you an idea of the kinds of things that can be done with Stata. To fully describe Stata 
programming would require more space than is available here. In fact, it fills an entire book in the 
Stata manuals. 
Using macros 
Macro assign a set of word or a number to a name. There are two types of macros. 
“Global” macros stay in memory until you leave Stata 
“Local” macros exist only with a program or a loop 
The syntax is relatively simple: 
global gmname = “ expression “ 
local  lmname = “ expression “ 
To use these macros later, you must use special symbols to tell Stata they are macros: 
$gmname 
`lmname‟ 
One use of the global macro is to store the name of the folder with the data.
global path = “d:\Bhutan\2003 BLSS\Stata” 
use “$path\food expenditure.dta”, clear 
In addition to saving you some time, this macro is useful if you share the program with others who 
have different names for the folders on their computer. By using the macro, your colleague can 
change the global command once rather than trying to change the path in every command that opens a 
file or saves a file.
Local macros are used (among other places) in loops with the while command, so we will discuss 
them in the next section.

Download 1.39 Mb.

Do'stlaringiz bilan baham:
1   ...   53   54   55   56   57   58   59   60   61




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling