Define different categories?

#1
Hello all,

I am fairly new to stata... I have the results of a large survey and I want to split my sample into two categories depending on the results of one specific question. That is, I want to divide this into people who said yes or no on a particular question. How do I go about doing this using Stata?

Further, after doing this, how can I get descriptive statistics for the different categories. For example, I want to know the percentage of people who responded yes on question 2 given they are in one of the pre-specified categories.

I hope that makes sense! Anything (even a small nudge in the right direction) would be greatly appreciated.

All the best,

Nick
 
#2
When you say split do you mean split into two datasets? Or just to be able to give it some kind of identifier?

If you want to perform analysis depending on the answer to "question2" where someone can answer 0 or 1 you can either use

bysort question2: command

or
command if question2==1
command if question2==0

where "command" is something like a summarize statement. If its all in the same dataset.

I'm not really sure I understand what you mean by the "pre-specified" categories so this might not really help, if you can provide a bit more info or an example that would be good. You can probably use an "and" statement to help.
 
Last edited: