Hello all,
I am new to Stata and I'm having some trouble working out the easiest way to display percentages in a markstat report.
I have to prepare a report using markstat which requires me to list simple percentages of many variables. I have a dataset with around 50,000 observations and 20 or so variables, which report on things like ethnicity, health status, location, gender etc. Most of these variables have around 4 or 5 possible categories.
In the report there are around 50 or so instances of stats like "x percent of the students are female", "x percent of the students have a health condition", and so on. Ideally I would like to be able to calculate these numbers dynamically, so they can go into a markstat document inline, using a single line of code if possible. I'm looking for something like
but that gives me a type mismatch error. I know that the count command will store a result as r(N), so I could do something like
but that's two lines of code which is a bit unwieldy to use inline with markstat. There are also a few occasions where I'll need two different values of r(N) and I'm not sure how to do that.
Any help would be much appreciated.
Regards,
Tex
I am new to Stata and I'm having some trouble working out the easiest way to display percentages in a markstat report.
I have to prepare a report using markstat which requires me to list simple percentages of many variables. I have a dataset with around 50,000 observations and 20 or so variables, which report on things like ethnicity, health status, location, gender etc. Most of these variables have around 4 or 5 possible categories.
In the report there are around 50 or so instances of stats like "x percent of the students are female", "x percent of the students have a health condition", and so on. Ideally I would like to be able to calculate these numbers dynamically, so they can go into a markstat document inline, using a single line of code if possible. I'm looking for something like
Code:
count if gender == "female" / _N
Code:
count if gender == "female" display r(N) / _N
Any help would be much appreciated.
Regards,
Tex

Comment