Longitudinal and Panel Data: Analysis and Applications for the Social Sciences 

SAS, Stata and R Code

Here are some examples of code to show the analysis displayed in the text. The files below are text files although they may have different extensions according to statistical software packages they were written.  SAS code has the extension of “.sas”, Stata code has the extension of “.do” and R code has the extension of “.txt”.

Note: * indicates use of PROC IML in SAS.

 

SAS

Stata

R

Chapter Title

Chapter 1

Divorce Analysis

Divorce Analysis

Divorce Analysis

Introduction

Chapter 2

Medicare Analysis

Medicare Analysis

Medicare Analysis

Fixed Effects Models

Section 2.4.3

*Influence Diagnostics

 

 

 

Section 2.4.4

*Cross-Sectional Correlations

 

 

 

Chapter 3

Taxprep Analysis

Taxprep Analysis

Taxprep Analysis

Models with Random Effects

Chapter 4 Section 4.1

ANOVA Model Predictions

 

 

Prediction and Bayesian Inference

Section 4.5

Lottery Exploration

Lottery Exploration

Lottery Exploration

 

Section 4.5

*Lottery In-Sample Analysis

Lottery In-Sample Analysis

Lottery In-Sample Analysis

 

Section 4.5

Lottery Out-of-Sample Analysis

 

 

 

Section 4.5

*Lottery Forecasting

 

 

 

Chapter 5 Section 5.2

Dental Analysis

Dental Analysis

Dental Analysis

Multilevel Models

Chapter 6 Section 6.2 & 6.3

 

Taxprep Endogeneity Analysis

Arellano-Bond Linear, Dynamic Panel Data Estimator

 

Stochastic Regressors

Chapter 7

Taxprep Analysis

Taxprep Analysis 

Taxprep Analysis 

Modeling Issues

Chapter 8 Section 8.6

Insurance Beta

Insurance Beta

Insurance Beta

Dynamic Models

Section 8.6

*CAPM Kalman Filter Estimation

 

 

 

Section 8.6

*CAPM Prediction

 

 

 

Chapter 9

Tax Preparer

Tax Preparer

Tax Preparer

Binary Dependent Variables

Chapter 10

Tort Filings

Tort Filings

Tort Filings

Generalized Linear Models

Chapter 11

Yogurt Choice 

Tax Preparer Choice

Yogurt Choice 

 

Yogurt Choice 

 

Categorical Dependent Variables and Survival Models

Supplemental Information

 Summary of Commands

Summary of Commands

Summary of Commands

 

 Download Section2.5Example, shows how to calculate robust standard errors, serial correlations and variables slopes (FE models).