SlideShare a Scribd company logo
1 of 53
Download to read offline
Introducing STATA
What is STATA
• Is a powerful statistical package with
• smart data-management facilities,
• a wide array of up-to-date statistical techniques, and
• an excellent system for producing publication-quality graphs.
• Stata is fast and easy to use.
What can Stata do?
• Stata is a command-driven package.
• The newest versions (Version 13 &14 ) also have pull-down menus
• The best way to learn Stata is still by typing in the commands.
• It is the typing of commands that makes Stata more interactive and
flexible than using pull-down menus
• Sometimes the exact syntax of a command is hard to get right – in
these cases, it is often advised to use the menu-commands to do it once
and then copy the syntax, which is automatically inserted in the
Command Window after executing any command (including from
pull-down menus).
• Alternatively, use HELP to get a syntax
The Stata Interface
• The core of Stata’s interface: its main windows, its toolbar, its menus,
and its dialogs.
The Stata Interface
Stata windows…
• These five windows( Command, results, variables, review, and
Properties) are typically in use the whole time Stata is open.
• There are other, more specialized windows such as the Viewer, Data
Editor, Variables Manager, Do-file Editor, Graph, and Graph Editor
Windows.
The commands window:
• Commands are submitted to Stata from the Command window.
• Supports basic text editing, copying and pasting, and a command
history.
The Results window:
• Contains all the commands and their textual results you have entered
during the Stata session.
• You can clear out the Results window at any time by right- clicking in
the Results window and selecting Clear Results from the contextual
menu.
• This action is not undoable
The Review window
• Shows the history of commands that have been entered.
• It displays successful commands in black and unsuccessful commands,
along with their error codes, in red.
• The command history allows you to recall a previously submitted
command, edit it if you wish, and then resubmit it.
• To enter a command from the Review window:
• You can click once on a past command to copy it to the Command
window, replacing the contents of the Command window; or
• Double-click on a past command to resubmit it.
The variables window:
• Shows the list of variables in the dataset, along with selected
properties of the variables.
• By default, it shows all the variables and their variable labels.
• Double-clicking on a variable in the Variables window puts the
selected variable at the insertion point in the Command window.
• The Variables window supports filtering and reordering of variables.
The Properties windows:
• Displays variable and dataset properties.
• If a single variable is selected in the Variables window, its properties
are displayed.
• If there are multiple variables selected in the Variables window, the
Properties window will display properties that are common across all
selected variables.
The Tool Bars
Menus and dialogs
• There are two ways by which you can tell Stata what you would like it
to do:
• You can use menus and dialogs, or
• You can use the Command window.
• For example, you could type Stata’s regress command, or you could
select
Statistics > Linear models and related > linear regression
Reading Data into Stata
For the data that are already in the Stata format
 Double click the Stata data file to load it into Stata OR
File > open >locate the file in your computer > Click on the file >
click on open
You can also use the “open” icon on the manu bar to do the same as 2)
above
Open > locate the file in your computer > Click on the file > click on open
Reading Data into Stata…
For data in other formats:
File > import > choose formate of your dataset (e.g. Excel
spreadsheet) > Browse excel file > tick import firest row as variable
names > Ok
Reading Data into Stata…
• The command window can also be used to load data into Stata using:
• the use, import command for data in Stata format; and
Example: use "C:UsersuserDesktopdata_phdNewdata2responserate.dta", clear
• the import and insheet commands for the other data formats.
Example: import excel "C:UsersuserDesktopdata_phdNew data2responserate.xls",
sheet("Sheet1") firstrow
• The clear option will clear any dataset currently in memory before
opening the new dataset.
• The sheet(“Sheet1”) option indicates that the data is in the first sheet
of the excel file.
• The fisrtrow option indicates that first row of the data has the variable
names
Saving data in Stata
• To save a dataset that has been changed (overwriting the original
data file):
1. select File > Save;
2. click on the Save button; or
3. type save, replace in the Command window
• To save a dataset for the first time
1. select File > Save As... and use the Save As dialog box to complete
the saving.
Stata Documentation: Keeping Track of
Things
Do-file
• It is a file containing a list of commands for Stata to run (called a
batch file or a script in other settings).
• Used to build up a series of commands that can then be submitted to
Stata all at once.
• It is used when writing a loop to process multiple variables in a similar
fashion or when doing complex, repetitive tasks interactively.
• A do-file can be launched by either clicking on the Do-file editor
button or by typing doedit in the command window
• Do-files have a toolbar as shown below:
•
Do-file…
• The diagram below shows how a do-file looks like:
Logs Files
• Stata has a lab notebook at hand: the log file.
• A log file is simply a record of your Results window.
• It records all commands and all textual output as it happens.
• Thus it keeps your lab notebook for you as you work.
• It also protects you from disastrous failures, be they power failures or
computer crashes.
• It is recommend that you start a log file whenever you begin any
serious work in Stata
Logs Files…
• To start a log file, click on the Log button. This will open a standard
file dialog that allows you to specify a directory and filename for your
log.
• The extension .smcl will be added to the filename.
• You can view the log file using the Viewer window in two ways:
1. Viewer > file > open...>Browse
• 2. File > log> view…
Data Management
1. The Data Editor
• Gives a spreadsheet-like view of data that are currently in memory.
• It can be used to enter new data, edit existing data, and edit attributes of the
data in the dataset, such as variable names, labels, and display formats, as
well as value labels.
• The Data Editor has two modes: edit mode for active editing and browse
mode for viewing
• Browse mode protect your data from inadvertent changes( because editing
within the data editor window is disabled)
• Browse mode is highly recommend that you use the Data Editor in browse
mode and switch to edit mode only when you want to make changes
2. Variable Manager
• A tool for managing properties of variables both individually and in
groups.
• It can be used to create variable and value labels, rename variables,
change display formats, and manage notes.
• It has the ability to filter and group variables as well as to create
variable lists.
• Open the Variables Manager by selecting Data > Variables
Manager or clicking on the Variables Manager button.
3. Labelling Data
• Naming of variables and labeling of variables and values.
• Naming and labeling is critical to careful use of data.
• Labeling variables with descriptive names clarifies their meanings.
• Labeling values of numerical categorical variables ensures that the
real world meanings of the encodings are not forgotten.
Labelling Data…
2.1. Naming variables
• Variable names can have up to 32 characters, but many commands print
only 12, and shorter names are easier to type.
• Stata names are case sensitive, Age and age are different variables!
• It helps to use short lowercase names and single words or abbreviations
rather than multi-word names,
• Note the use of underscores to separate words.
Labelling Data…
2.2. Labeling variables
• Variables can be labeled using the following Stata command
label var var1 “description”
• Where var1 is the variable to be labeled; and description is the label
of var1
• Example: Label a variable called age as “Age of study Participants”
• Write this: label variable age "Age of study participant" on command
window, then enter.
Labelling Data…
2.3. Labeling the various levels of a categorical variable
• The various levels of a categorical variable can be labeled using the
following two Stata Commands together:
• label define var1 1 “name of the first category” 2 “name of the second category”
• label values var1 var1
• Where var1 is the name of the categorical variable; and 1 and 2 are the
levels of the categorical variable.
• Example: A variable called gender has two categories – 1 for male and
2 for female. The categories if gender can be labeled as follows:
• label define gender 1 “male” 2 “female”
• label values gender gender
4. Generating new variables from existing variables(s)
• The generate and replace commands allow us to create new variables or
change the values of existing variables
• Command: generate new_variable = expression
• Example: Generate a variable called income which is the sum of farm
income (fincome) and nonfarm income (nfincome):
• generate income = fincome + nfincome
• Generate new variable using Functions:
• generate loginc = ln(income)
Generating new variables…
• generate can create new variables, and replace can produce new
values, using any mixture of old variables, constants, random values
and expressions.
• The operator defined in Stata are:
Generating new variables…
• Another command that is frequently used with the generate command
is the replace command
• replace modifies the content of a variable by replacing some or all of
its continent
• Command: replace var1 = a if var1==b
• where var1 is the variable to be modified; a is the replacement; and b
is the content of var1 that is to be replaced.
5. Keep and drop
• The original dataset may contain variables you are not interested in or
observations you don’t want to analyze.
• You can tell Stata to either keep what you want or drop what you don’t
want
• Command
• keep var1 var2
• drop var3 var3
Examining the Data
Use fieldepidemiologydata3.xls
It is a good idea to examine your data when you first read it
into Stata – you should check that all the variables and
observations are present and in the correct format.
1. List command
• Use the list command to examine raw data within the results window
• Listing the entire dataset is only feasible if it is small.
• The list command displays the values of variables.
• If no varlist is specified, the values of all the variables are displayed.
• Command/Syntax: list varlist , options
• Where varlist is the list of variables to be listed; and options is any or
a combination of any of the options associated with the list command.
2. Browse/Edit
• The browse command is similar to edit, except that modifications
to the data by editing in the grid are not permitted.
• browse is a convenient alternative to the list command.
• The edit command brings up a spreadsheet-style data editor for
entering new data and editing existing data.
• The edit allows you to manually change the dataset.
• Command:
• edit varlist or
• browse varlist
browse sex ses tg icecream salad
3. Describe
• The describe command produces a summary of the dataset in memory
or of the data stored in a Stata-format dataset.
• Command: describe varlist
4. Summarize
• This provides summary statistics, such as means, standard deviations,
and so on. Command: summarize varlists, options
5. Tabulate
• The tabulate command used to produce a frequency table of one
variable or a cross-tab of two variables.
• Command: 1) tabulate varname, options
• Command: 2) tabulate varname1 varname2, option
6. Graph
• The graph commands draws graph
• The “Graph” tab on the manu bar can also be used.
7. Correlations
• Measures association/relationship between variables.
• correlate command displays the correlation matrix or covariance
matrix for a group of variables.
• pwcorr command displays all pairwise correlation coefficients
between variables
• Command 1: correlate variable_list, options
• Command 2: pwcorr variable_list, options
t-test
One Way ANOVA
Regression
Using STATA Version 14
One-sample t-test using Stata
• Command: ttest Var == Hypothesized Value
• Example: ttest fbs ==0.5
Independent t-test using Stata
• Command: ttest DependentVariable, by(IndependentVariable)
• Example: ttest fbs, by(sex)
Paired t-test using Stata
• Command: ttest FirstVariable == SecondVariable
• Example: ttest pretest = = posttest
One-way ANOVA using Stata
• Command: oneway Dependent Variable Independent Variable, tabulate
• If there is a statistically significant difference between your groups, you can
then carry out post hoc tests (Bonferroni, Sidak, Scheffe, Tukey, etc) using
the code below to determine where any differences lie.
• Post hoc test command: pwmean Dependent Variable, over(Independent
Variable) mcompare(tukey) effects
Linear regression analysis using Stata
• Command: regress Dependent Variable Independent Variable
•
Multiple linear Regression Analysis using Stata
• Command: regress Dependent Variable IndependentVariable#1
IndependentVariable#2 IndependentVariable#3 IndependentVariable#4
Binomial Logistic Regression Analysis using Stata
• Command: logistic Dependent Variable IndependentVariable#1
IndependentVariable#3 IndependentVariable#4, option
Use hepatitis. Dta data set
Thank You

More Related Content

What's hot

SPSS introduction Presentation
SPSS introduction Presentation SPSS introduction Presentation
SPSS introduction Presentation befikra
 
SPSS :Introduction for beginners
SPSS :Introduction for beginners SPSS :Introduction for beginners
SPSS :Introduction for beginners PRAKASAM C P
 
Introduction to statistics
Introduction to statisticsIntroduction to statistics
Introduction to statisticsmadan kumar
 
Introduction To Statistics
Introduction To StatisticsIntroduction To Statistics
Introduction To Statisticsalbertlaporte
 
Basic guide to SPSS
Basic guide to SPSSBasic guide to SPSS
Basic guide to SPSSpaul_gorman
 
Four data types Data Scientist should know
Four data types Data Scientist should knowFour data types Data Scientist should know
Four data types Data Scientist should knowRanjit Nambisan
 
what is statistics? Mc Graw Hills/Irwin
what is statistics? Mc Graw Hills/Irwinwhat is statistics? Mc Graw Hills/Irwin
what is statistics? Mc Graw Hills/IrwinMaryam Xahra
 
Logistic Ordinal Regression
Logistic Ordinal RegressionLogistic Ordinal Regression
Logistic Ordinal RegressionSri Ambati
 
SPSS How to use Spss software
SPSS How to use Spss softwareSPSS How to use Spss software
SPSS How to use Spss softwareDebashis Baidya
 
An introduction to spss
An introduction to spssAn introduction to spss
An introduction to spsszeeshanwrch
 
introduction to spss
introduction to spssintroduction to spss
introduction to spssOmid Minooee
 
Statistics
StatisticsStatistics
Statisticsitutor
 

What's hot (20)

SPSS introduction Presentation
SPSS introduction Presentation SPSS introduction Presentation
SPSS introduction Presentation
 
SPSS :Introduction for beginners
SPSS :Introduction for beginners SPSS :Introduction for beginners
SPSS :Introduction for beginners
 
Descriptive statistics ii
Descriptive statistics iiDescriptive statistics ii
Descriptive statistics ii
 
Introduction to spss
Introduction to spssIntroduction to spss
Introduction to spss
 
Introduction to statistics
Introduction to statisticsIntroduction to statistics
Introduction to statistics
 
Introduction To Statistics
Introduction To StatisticsIntroduction To Statistics
Introduction To Statistics
 
Basic guide to SPSS
Basic guide to SPSSBasic guide to SPSS
Basic guide to SPSS
 
Spss tutorial 1
Spss tutorial 1Spss tutorial 1
Spss tutorial 1
 
Four data types Data Scientist should know
Four data types Data Scientist should knowFour data types Data Scientist should know
Four data types Data Scientist should know
 
Stata tutorial
Stata tutorialStata tutorial
Stata tutorial
 
Time series.ppt
Time series.pptTime series.ppt
Time series.ppt
 
what is statistics? Mc Graw Hills/Irwin
what is statistics? Mc Graw Hills/Irwinwhat is statistics? Mc Graw Hills/Irwin
what is statistics? Mc Graw Hills/Irwin
 
Logistic Ordinal Regression
Logistic Ordinal RegressionLogistic Ordinal Regression
Logistic Ordinal Regression
 
SPSS How to use Spss software
SPSS How to use Spss softwareSPSS How to use Spss software
SPSS How to use Spss software
 
SCATTER PLOTS
SCATTER PLOTSSCATTER PLOTS
SCATTER PLOTS
 
Descriptive statistics
Descriptive statisticsDescriptive statistics
Descriptive statistics
 
An introduction to spss
An introduction to spssAn introduction to spss
An introduction to spss
 
introduction to spss
introduction to spssintroduction to spss
introduction to spss
 
Bivariate data
Bivariate dataBivariate data
Bivariate data
 
Statistics
StatisticsStatistics
Statistics
 

Similar to Introduction to STATA(2).pdf

STATA_Training_for_data_science_juniors.pdf
STATA_Training_for_data_science_juniors.pdfSTATA_Training_for_data_science_juniors.pdf
STATA_Training_for_data_science_juniors.pdfAronMozart1
 
Mr20 enus 02-Report Design in Management Reporter 2.0 for Microsoft Dynamics®...
Mr20 enus 02-Report Design in Management Reporter 2.0 for Microsoft Dynamics®...Mr20 enus 02-Report Design in Management Reporter 2.0 for Microsoft Dynamics®...
Mr20 enus 02-Report Design in Management Reporter 2.0 for Microsoft Dynamics®...Sami JAMMALI
 
Obiee metadata development
Obiee metadata developmentObiee metadata development
Obiee metadata developmentdils4u
 
Advanced Filter Concepts in MS-Excel
Advanced Filter Concepts in MS-ExcelAdvanced Filter Concepts in MS-Excel
Advanced Filter Concepts in MS-ExcelP. SUNDARI ARUN
 
Salesforce Developer Console ppt
Salesforce Developer Console  pptSalesforce Developer Console  ppt
Salesforce Developer Console pptKuhinoor Alom
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptxTadiwaMawere
 
Tableau Basic Questions
Tableau Basic QuestionsTableau Basic Questions
Tableau Basic QuestionsSooraj Vinodan
 
Generic steps in informatica
Generic steps in informaticaGeneric steps in informatica
Generic steps in informaticaBhuvana Priya
 
Pl sql best practices document
Pl sql best practices documentPl sql best practices document
Pl sql best practices documentAshwani Pandey
 
Jaspersoft and Clarity PPM - Advanced Reporting with Data Warehouse
Jaspersoft and Clarity PPM - Advanced Reporting with Data WarehouseJaspersoft and Clarity PPM - Advanced Reporting with Data Warehouse
Jaspersoft and Clarity PPM - Advanced Reporting with Data WarehouseThiago Bottoni
 
An introduction to STATA.pdf
An introduction to STATA.pdfAn introduction to STATA.pdf
An introduction to STATA.pdfMd Nain
 
Style Intelligence User Documentation
Style Intelligence User DocumentationStyle Intelligence User Documentation
Style Intelligence User DocumentationArleneWatson
 
Katalon Studio - GUI Overview
Katalon Studio - GUI OverviewKatalon Studio - GUI Overview
Katalon Studio - GUI OverviewKatalon Studio
 
PowerShell Plus v4.7 Overview
PowerShell Plus v4.7 OverviewPowerShell Plus v4.7 Overview
PowerShell Plus v4.7 OverviewRichard Giles
 

Similar to Introduction to STATA(2).pdf (20)

STATA_Training_for_data_science_juniors.pdf
STATA_Training_for_data_science_juniors.pdfSTATA_Training_for_data_science_juniors.pdf
STATA_Training_for_data_science_juniors.pdf
 
Mr20 enus 02-Report Design in Management Reporter 2.0 for Microsoft Dynamics®...
Mr20 enus 02-Report Design in Management Reporter 2.0 for Microsoft Dynamics®...Mr20 enus 02-Report Design in Management Reporter 2.0 for Microsoft Dynamics®...
Mr20 enus 02-Report Design in Management Reporter 2.0 for Microsoft Dynamics®...
 
Obiee metadata development
Obiee metadata developmentObiee metadata development
Obiee metadata development
 
Advanced Filter Concepts in MS-Excel
Advanced Filter Concepts in MS-ExcelAdvanced Filter Concepts in MS-Excel
Advanced Filter Concepts in MS-Excel
 
Salesforce Developer Console ppt
Salesforce Developer Console  pptSalesforce Developer Console  ppt
Salesforce Developer Console ppt
 
introduction-stata.pptx
introduction-stata.pptxintroduction-stata.pptx
introduction-stata.pptx
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptx
 
Data stage
Data stageData stage
Data stage
 
Tableau Basic Questions
Tableau Basic QuestionsTableau Basic Questions
Tableau Basic Questions
 
Generic steps in informatica
Generic steps in informaticaGeneric steps in informatica
Generic steps in informatica
 
Pl sql best practices document
Pl sql best practices documentPl sql best practices document
Pl sql best practices document
 
Jaspersoft and Clarity PPM - Advanced Reporting with Data Warehouse
Jaspersoft and Clarity PPM - Advanced Reporting with Data WarehouseJaspersoft and Clarity PPM - Advanced Reporting with Data Warehouse
Jaspersoft and Clarity PPM - Advanced Reporting with Data Warehouse
 
An introduction to STATA.pdf
An introduction to STATA.pdfAn introduction to STATA.pdf
An introduction to STATA.pdf
 
Style Intelligence User Documentation
Style Intelligence User DocumentationStyle Intelligence User Documentation
Style Intelligence User Documentation
 
Katalon Studio - GUI Overview
Katalon Studio - GUI OverviewKatalon Studio - GUI Overview
Katalon Studio - GUI Overview
 
Visual basic
Visual basicVisual basic
Visual basic
 
PowerShell Plus v4.7 Overview
PowerShell Plus v4.7 OverviewPowerShell Plus v4.7 Overview
PowerShell Plus v4.7 Overview
 
Visual Basic.pptx
Visual Basic.pptxVisual Basic.pptx
Visual Basic.pptx
 
Datastage Introduction To Data Warehousing
Datastage Introduction To Data WarehousingDatastage Introduction To Data Warehousing
Datastage Introduction To Data Warehousing
 
Understanding Microsoft Access
Understanding Microsoft AccessUnderstanding Microsoft Access
Understanding Microsoft Access
 

More from Yomif3

Neonatal TETANUS (1).pptx
Neonatal TETANUS (1).pptxNeonatal TETANUS (1).pptx
Neonatal TETANUS (1).pptxYomif3
 
8. Acute Rheumatic fever (1).ppt
8.  Acute Rheumatic fever (1).ppt8.  Acute Rheumatic fever (1).ppt
8. Acute Rheumatic fever (1).pptYomif3
 
TORCH Infections.pptx
TORCH Infections.pptxTORCH Infections.pptx
TORCH Infections.pptxYomif3
 
neurology (1).pptx
neurology (1).pptxneurology (1).pptx
neurology (1).pptxYomif3
 
Pedi HIV (1).pptx
Pedi HIV (1).pptxPedi HIV (1).pptx
Pedi HIV (1).pptxYomif3
 
Meningitis and Encephalitis.pptx
Meningitis and Encephalitis.pptxMeningitis and Encephalitis.pptx
Meningitis and Encephalitis.pptxYomif3
 
Female Reproductive m3.ppt
Female Reproductive m3.pptFemale Reproductive m3.ppt
Female Reproductive m3.pptYomif3
 
Male Reproductive m3 (2).ppt
Male Reproductive m3 (2).pptMale Reproductive m3 (2).ppt
Male Reproductive m3 (2).pptYomif3
 
Tissue renewal and healing.pptx
Tissue renewal and healing.pptxTissue renewal and healing.pptx
Tissue renewal and healing.pptxYomif3
 
Introduction to pathology.pptx
Introduction to pathology.pptxIntroduction to pathology.pptx
Introduction to pathology.pptxYomif3
 
Inflammation (2).pptx
Inflammation (2).pptxInflammation (2).pptx
Inflammation (2).pptxYomif3
 
neoplasia 2 (2).ppt
neoplasia 2 (2).pptneoplasia 2 (2).ppt
neoplasia 2 (2).pptYomif3
 
Introduction to Epi Info.pdf
Introduction to Epi Info.pdfIntroduction to Epi Info.pdf
Introduction to Epi Info.pdfYomif3
 
1 Introduction to SPSS.pdf
1 Introduction to SPSS.pdf1 Introduction to SPSS.pdf
1 Introduction to SPSS.pdfYomif3
 

More from Yomif3 (14)

Neonatal TETANUS (1).pptx
Neonatal TETANUS (1).pptxNeonatal TETANUS (1).pptx
Neonatal TETANUS (1).pptx
 
8. Acute Rheumatic fever (1).ppt
8.  Acute Rheumatic fever (1).ppt8.  Acute Rheumatic fever (1).ppt
8. Acute Rheumatic fever (1).ppt
 
TORCH Infections.pptx
TORCH Infections.pptxTORCH Infections.pptx
TORCH Infections.pptx
 
neurology (1).pptx
neurology (1).pptxneurology (1).pptx
neurology (1).pptx
 
Pedi HIV (1).pptx
Pedi HIV (1).pptxPedi HIV (1).pptx
Pedi HIV (1).pptx
 
Meningitis and Encephalitis.pptx
Meningitis and Encephalitis.pptxMeningitis and Encephalitis.pptx
Meningitis and Encephalitis.pptx
 
Female Reproductive m3.ppt
Female Reproductive m3.pptFemale Reproductive m3.ppt
Female Reproductive m3.ppt
 
Male Reproductive m3 (2).ppt
Male Reproductive m3 (2).pptMale Reproductive m3 (2).ppt
Male Reproductive m3 (2).ppt
 
Tissue renewal and healing.pptx
Tissue renewal and healing.pptxTissue renewal and healing.pptx
Tissue renewal and healing.pptx
 
Introduction to pathology.pptx
Introduction to pathology.pptxIntroduction to pathology.pptx
Introduction to pathology.pptx
 
Inflammation (2).pptx
Inflammation (2).pptxInflammation (2).pptx
Inflammation (2).pptx
 
neoplasia 2 (2).ppt
neoplasia 2 (2).pptneoplasia 2 (2).ppt
neoplasia 2 (2).ppt
 
Introduction to Epi Info.pdf
Introduction to Epi Info.pdfIntroduction to Epi Info.pdf
Introduction to Epi Info.pdf
 
1 Introduction to SPSS.pdf
1 Introduction to SPSS.pdf1 Introduction to SPSS.pdf
1 Introduction to SPSS.pdf
 

Recently uploaded

20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdfHuman37
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一F La
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceSapana Sha
 
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degreeyuu sss
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一
办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一
办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一F La
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)jennyeacort
 
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...Boston Institute of Analytics
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理e4aez8ss
 
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAmazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAbdelrhman abooda
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhijennyeacort
 
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...limedy534
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home ServiceSapana Sha
 
RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.natarajan8993
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样vhwb25kk
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 

Recently uploaded (20)

20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts Service
 
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一
办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一
办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
 
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
 
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
 
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAmazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
 
Call Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort ServiceCall Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort Service
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
 
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
 
E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service
 
RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 

Introduction to STATA(2).pdf

  • 1. Introducing STATA What is STATA • Is a powerful statistical package with • smart data-management facilities, • a wide array of up-to-date statistical techniques, and • an excellent system for producing publication-quality graphs. • Stata is fast and easy to use.
  • 2. What can Stata do? • Stata is a command-driven package. • The newest versions (Version 13 &14 ) also have pull-down menus • The best way to learn Stata is still by typing in the commands. • It is the typing of commands that makes Stata more interactive and flexible than using pull-down menus • Sometimes the exact syntax of a command is hard to get right – in these cases, it is often advised to use the menu-commands to do it once and then copy the syntax, which is automatically inserted in the Command Window after executing any command (including from pull-down menus). • Alternatively, use HELP to get a syntax
  • 3. The Stata Interface • The core of Stata’s interface: its main windows, its toolbar, its menus, and its dialogs.
  • 5. Stata windows… • These five windows( Command, results, variables, review, and Properties) are typically in use the whole time Stata is open. • There are other, more specialized windows such as the Viewer, Data Editor, Variables Manager, Do-file Editor, Graph, and Graph Editor Windows.
  • 6. The commands window: • Commands are submitted to Stata from the Command window. • Supports basic text editing, copying and pasting, and a command history.
  • 7. The Results window: • Contains all the commands and their textual results you have entered during the Stata session. • You can clear out the Results window at any time by right- clicking in the Results window and selecting Clear Results from the contextual menu. • This action is not undoable
  • 8. The Review window • Shows the history of commands that have been entered. • It displays successful commands in black and unsuccessful commands, along with their error codes, in red. • The command history allows you to recall a previously submitted command, edit it if you wish, and then resubmit it. • To enter a command from the Review window: • You can click once on a past command to copy it to the Command window, replacing the contents of the Command window; or • Double-click on a past command to resubmit it.
  • 9. The variables window: • Shows the list of variables in the dataset, along with selected properties of the variables. • By default, it shows all the variables and their variable labels. • Double-clicking on a variable in the Variables window puts the selected variable at the insertion point in the Command window. • The Variables window supports filtering and reordering of variables.
  • 10. The Properties windows: • Displays variable and dataset properties. • If a single variable is selected in the Variables window, its properties are displayed. • If there are multiple variables selected in the Variables window, the Properties window will display properties that are common across all selected variables.
  • 12. Menus and dialogs • There are two ways by which you can tell Stata what you would like it to do: • You can use menus and dialogs, or • You can use the Command window. • For example, you could type Stata’s regress command, or you could select Statistics > Linear models and related > linear regression
  • 13. Reading Data into Stata For the data that are already in the Stata format  Double click the Stata data file to load it into Stata OR File > open >locate the file in your computer > Click on the file > click on open You can also use the “open” icon on the manu bar to do the same as 2) above Open > locate the file in your computer > Click on the file > click on open
  • 14. Reading Data into Stata… For data in other formats: File > import > choose formate of your dataset (e.g. Excel spreadsheet) > Browse excel file > tick import firest row as variable names > Ok
  • 15. Reading Data into Stata… • The command window can also be used to load data into Stata using: • the use, import command for data in Stata format; and Example: use "C:UsersuserDesktopdata_phdNewdata2responserate.dta", clear • the import and insheet commands for the other data formats. Example: import excel "C:UsersuserDesktopdata_phdNew data2responserate.xls", sheet("Sheet1") firstrow • The clear option will clear any dataset currently in memory before opening the new dataset. • The sheet(“Sheet1”) option indicates that the data is in the first sheet of the excel file. • The fisrtrow option indicates that first row of the data has the variable names
  • 16. Saving data in Stata • To save a dataset that has been changed (overwriting the original data file): 1. select File > Save; 2. click on the Save button; or 3. type save, replace in the Command window • To save a dataset for the first time 1. select File > Save As... and use the Save As dialog box to complete the saving.
  • 17. Stata Documentation: Keeping Track of Things
  • 18. Do-file • It is a file containing a list of commands for Stata to run (called a batch file or a script in other settings). • Used to build up a series of commands that can then be submitted to Stata all at once. • It is used when writing a loop to process multiple variables in a similar fashion or when doing complex, repetitive tasks interactively. • A do-file can be launched by either clicking on the Do-file editor button or by typing doedit in the command window • Do-files have a toolbar as shown below: •
  • 19. Do-file… • The diagram below shows how a do-file looks like:
  • 20. Logs Files • Stata has a lab notebook at hand: the log file. • A log file is simply a record of your Results window. • It records all commands and all textual output as it happens. • Thus it keeps your lab notebook for you as you work. • It also protects you from disastrous failures, be they power failures or computer crashes. • It is recommend that you start a log file whenever you begin any serious work in Stata
  • 21. Logs Files… • To start a log file, click on the Log button. This will open a standard file dialog that allows you to specify a directory and filename for your log. • The extension .smcl will be added to the filename. • You can view the log file using the Viewer window in two ways: 1. Viewer > file > open...>Browse • 2. File > log> view…
  • 23. 1. The Data Editor • Gives a spreadsheet-like view of data that are currently in memory. • It can be used to enter new data, edit existing data, and edit attributes of the data in the dataset, such as variable names, labels, and display formats, as well as value labels. • The Data Editor has two modes: edit mode for active editing and browse mode for viewing • Browse mode protect your data from inadvertent changes( because editing within the data editor window is disabled) • Browse mode is highly recommend that you use the Data Editor in browse mode and switch to edit mode only when you want to make changes
  • 24. 2. Variable Manager • A tool for managing properties of variables both individually and in groups. • It can be used to create variable and value labels, rename variables, change display formats, and manage notes. • It has the ability to filter and group variables as well as to create variable lists. • Open the Variables Manager by selecting Data > Variables Manager or clicking on the Variables Manager button.
  • 25. 3. Labelling Data • Naming of variables and labeling of variables and values. • Naming and labeling is critical to careful use of data. • Labeling variables with descriptive names clarifies their meanings. • Labeling values of numerical categorical variables ensures that the real world meanings of the encodings are not forgotten.
  • 26. Labelling Data… 2.1. Naming variables • Variable names can have up to 32 characters, but many commands print only 12, and shorter names are easier to type. • Stata names are case sensitive, Age and age are different variables! • It helps to use short lowercase names and single words or abbreviations rather than multi-word names, • Note the use of underscores to separate words.
  • 27. Labelling Data… 2.2. Labeling variables • Variables can be labeled using the following Stata command label var var1 “description” • Where var1 is the variable to be labeled; and description is the label of var1 • Example: Label a variable called age as “Age of study Participants” • Write this: label variable age "Age of study participant" on command window, then enter.
  • 28. Labelling Data… 2.3. Labeling the various levels of a categorical variable • The various levels of a categorical variable can be labeled using the following two Stata Commands together: • label define var1 1 “name of the first category” 2 “name of the second category” • label values var1 var1 • Where var1 is the name of the categorical variable; and 1 and 2 are the levels of the categorical variable. • Example: A variable called gender has two categories – 1 for male and 2 for female. The categories if gender can be labeled as follows: • label define gender 1 “male” 2 “female” • label values gender gender
  • 29. 4. Generating new variables from existing variables(s) • The generate and replace commands allow us to create new variables or change the values of existing variables • Command: generate new_variable = expression • Example: Generate a variable called income which is the sum of farm income (fincome) and nonfarm income (nfincome): • generate income = fincome + nfincome • Generate new variable using Functions: • generate loginc = ln(income)
  • 30. Generating new variables… • generate can create new variables, and replace can produce new values, using any mixture of old variables, constants, random values and expressions. • The operator defined in Stata are:
  • 31. Generating new variables… • Another command that is frequently used with the generate command is the replace command • replace modifies the content of a variable by replacing some or all of its continent • Command: replace var1 = a if var1==b • where var1 is the variable to be modified; a is the replacement; and b is the content of var1 that is to be replaced.
  • 32. 5. Keep and drop • The original dataset may contain variables you are not interested in or observations you don’t want to analyze. • You can tell Stata to either keep what you want or drop what you don’t want • Command • keep var1 var2 • drop var3 var3
  • 33. Examining the Data Use fieldepidemiologydata3.xls It is a good idea to examine your data when you first read it into Stata – you should check that all the variables and observations are present and in the correct format.
  • 34. 1. List command • Use the list command to examine raw data within the results window • Listing the entire dataset is only feasible if it is small. • The list command displays the values of variables. • If no varlist is specified, the values of all the variables are displayed. • Command/Syntax: list varlist , options • Where varlist is the list of variables to be listed; and options is any or a combination of any of the options associated with the list command.
  • 35. 2. Browse/Edit • The browse command is similar to edit, except that modifications to the data by editing in the grid are not permitted. • browse is a convenient alternative to the list command. • The edit command brings up a spreadsheet-style data editor for entering new data and editing existing data. • The edit allows you to manually change the dataset. • Command: • edit varlist or • browse varlist
  • 36. browse sex ses tg icecream salad
  • 37. 3. Describe • The describe command produces a summary of the dataset in memory or of the data stored in a Stata-format dataset. • Command: describe varlist
  • 38. 4. Summarize • This provides summary statistics, such as means, standard deviations, and so on. Command: summarize varlists, options
  • 39. 5. Tabulate • The tabulate command used to produce a frequency table of one variable or a cross-tab of two variables. • Command: 1) tabulate varname, options • Command: 2) tabulate varname1 varname2, option
  • 40.
  • 41. 6. Graph • The graph commands draws graph • The “Graph” tab on the manu bar can also be used.
  • 42. 7. Correlations • Measures association/relationship between variables. • correlate command displays the correlation matrix or covariance matrix for a group of variables. • pwcorr command displays all pairwise correlation coefficients between variables • Command 1: correlate variable_list, options • Command 2: pwcorr variable_list, options
  • 43.
  • 45. One-sample t-test using Stata • Command: ttest Var == Hypothesized Value • Example: ttest fbs ==0.5
  • 46. Independent t-test using Stata • Command: ttest DependentVariable, by(IndependentVariable) • Example: ttest fbs, by(sex)
  • 47. Paired t-test using Stata • Command: ttest FirstVariable == SecondVariable • Example: ttest pretest = = posttest
  • 48. One-way ANOVA using Stata • Command: oneway Dependent Variable Independent Variable, tabulate • If there is a statistically significant difference between your groups, you can then carry out post hoc tests (Bonferroni, Sidak, Scheffe, Tukey, etc) using the code below to determine where any differences lie. • Post hoc test command: pwmean Dependent Variable, over(Independent Variable) mcompare(tukey) effects
  • 49.
  • 50. Linear regression analysis using Stata • Command: regress Dependent Variable Independent Variable •
  • 51. Multiple linear Regression Analysis using Stata • Command: regress Dependent Variable IndependentVariable#1 IndependentVariable#2 IndependentVariable#3 IndependentVariable#4
  • 52. Binomial Logistic Regression Analysis using Stata • Command: logistic Dependent Variable IndependentVariable#1 IndependentVariable#3 IndependentVariable#4, option Use hepatitis. Dta data set