Hi. I have the following local which comprises of some continuous variables and some categorical variables. I need to generate summary statistics, mean and SD, along with the number of missing observations for each of these by a group variable “armcd”. I can do it for each variable individually as shown below, but was wondering if there is anyway I can do this through a loop to generate the summary stats, the number of missing values, and export them to excel.

Code:
local chars racecat1 age stkcat1n sscat2n sexn hisstktian medschcatn rucacat2n dc_ref dc_refhh pcpfln dualcatn medhisdpn medhishtn medhissmn anycvdn
bysort armcd: sum age
bysort armcd: tab racecat1n