Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Data Analysis with STATA

You're reading from  Data Analysis with STATA

Product type Book
Published in Oct 2015
Publisher Packt
ISBN-13 9781782173175
Pages 176 pages
Edition 1st Edition
Languages

Table of Contents (16) Chapters

Data Analysis with Stata
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Introduction to Stata and Data Analytics 2. Stata Programming and Data Management 3. Data Visualization 4. Important Statistical Tests in Stata 5. Linear Regression in Stata 6. Logistic Regression in Stata 7. Survey Analysis in Stata 8. Time Series Analysis in Stata 9. Survival Analysis in Stata Index

Pyramidal graphs


What if we need a pyramidal graph divided into all possible subcategories of the data? Here is your answer in terms of the Stata code:

egen scoregroup= cut(score), group(9) label
tab scoregroup

sort sex scoregroup session
contract sex scoregroup session
rename _freq cnt

reshape wide cnt, i(scoregroup sex) j(session)

gen d1 = cnt1 /*session = 1 */
gen d12 = cnt1+cnt2
gen d123 = cnt3 + d12
gen d1_n = - d1
gen d12_n = - d12
gen d123_n = - d123

gen zero = 0

label values scoregroup scoregroup
label values sex f1

twoway bar c123 scoregroup if sex==0 , horizontal || ///
  bar c12 scoregroup if sex==0, horizontal || ///
  bar c1 scoregroup if sex ==0, horizontal  || ///
  bar c123_n scoregroup if sex ==1 , horizontal || ///
  bar c12_n scoregroup if sex ==1, horizontal || ///
  bar c1_n scoregroup if sex ==1, horizontal || ///

  sc  scoregroup zero ,  mlabel(scoregroup) mlabsize(vsmall) ///
  mlabcolor(white) msymbol(i) || , plotregion(style(none)) ysca(dash) ///
  ylabel...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}