Gye Greene's Thoughts

Gye Greene's Thoughts (w/ apologies to The Smithereens and their similarly-titled album!)

Wednesday, March 07, 2012

Stats bilingual

In grad school, I started off with SPSS. Then for my Ph.D., I used Stata. I used Stata for all my research work since then.

But then at my current job (which I've now been at for more than a year!), I've been using SPSS -- because that's what was available.

And then, **now I have Stata again!!!

Although -- even though in previous posts I've clearly preferred Stata, it's not perfect: there are some advantages to SPSS. Stata maxes out at 1GB file sizes (for non- 64 bit computers), and (unlike with SPSS) you can't display the value **and** the value label at the same time (e.g. if 1=male and 0= female, you can have the percentage tables show "1" and "0" **or** "male" and "female" -- but not both at the same time).

But, I prefer how Stata handles missing values: you can toggle on or off whether you want missings to be displayed -- and you actually have the **choice** to include them in your percentage tables (whereas in SPSS it's not possible to display them.) On Stata, the default is to break on error -- and you can defeat that if you like -- whereas SPSS just plows through the whole script, and there's no way to get it to stop when it hits an error (I confirmed this with SPSS tech support).

And, I think the scripting language is cleaner in Stata. Below is a script in Stata, and then a functionally equivalent script in SPSS.


generate isolated_location_YES = Off_Loc_Isol_Recode
label value isolated_location_YES yesoth

replace isolated_location_YES=1 if Off_Loc_Isol_Recode==2
replace isolated_location_YES=0 if Off_Loc_Isol_Recode==1

*Verifying .

tab2 isolated_location_YES Off_Loc_Isol_Recode


compute isolated_location_YES = Off_Loc_Isol_Recode .
value labels isolated_location_YES 1 "Yes" 0 "No, other situation" .
execute .

if(Off_Loc_Isol_Recode=2) isolated_location_YES=1 .
if(Off_Loc_Isol_Recode=1) isolated_location_YES=0 .
execute .

*Verifying .

crosstabs /tables= isolated_location_YES by Off_Loc_Isol_Recode .

Same number of lines; but less typing with Stata.

Anyhow, it's interesting because now that I have both programs at work, I switch back and forth between them. It's like trying to switch between French and Spanish: similar, but with important differences -- such as in SPSS you must end each line with a period; but in Stata, that's an error. Or using ''double equals'' for conditional equivalencies (e.g. if gender equals 'male') in Stata, but single equals in SPSS.

But -- **extra** geeky. So it's all OK. :)


Labels: , , , ,


Post a Comment

<< Home