Hi all,
I have a large data set that I want to generate summary statistics for. I have a range of variables that I want to have generated but I can't seem to get for loops to work. Essentially, I want to have a table that generates 2 columns (1 for the Control Group and the other for the Intervention group) that has all the variables I want as new rows.
Below is an excerpt of my code with just a few of the variables I want to generate (age, race, sex, etc.). All variables are categorical variables. The code below yields the error r(109) "type mismatch" and I can't seem to figure out why. Any help will be much appreciated.
I have a large data set that I want to generate summary statistics for. I have a range of variables that I want to have generated but I can't seem to get for loops to work. Essentially, I want to have a table that generates 2 columns (1 for the Control Group and the other for the Intervention group) that has all the variables I want as new rows.
Below is an excerpt of my code with just a few of the variables I want to generate (age, race, sex, etc.). All variables are categorical variables. The code below yields the error r(109) "type mismatch" and I can't seem to figure out why. Any help will be much appreciated.
Code:
local sumstats racecat1n age stkcat1n sscat2n sexn hisstktian
local armcd CON INV
local armn 1 2
#delimit;
forvalues r=1/2{;
eststo `=word("`armcd'",`r')': estpost tabstat `sumstats' if armcd==`=word("`armn'",`r')', stat(mean sd) columns(stat) listwise;
};
esttab `armcd' using "$output/mcd_summarystats.tex", replace label
title ("Table 1: Baseline Characteristics by Arm for the Claims ITT Populations,")
addnotes("The means are reported with the standard deviations in parenthesis")
cells(mean(pattern(1 1) fmt(3)) sd(par pattern(1 1)fmt(2)) b(star pattern(0 0 1) fmt(2)))
mtitles( "UC" "INV")
varlabel(
racecat1n "Race Category"
stkcat1n "Stroke Diagnosis"
age "Age (years)"
sscat2n "NIHSS Category"
sexn "Sex"
hisstktian "History of Ssstroke or TIA") ;
#delimit cr

Comment