Deciding if coke is better than pepsi Suppose we go and ask a few subjects if they think coke is better than pepsi. We get some yes (1) and some no's (0). We find that there are more 1's than 0's, but not that many more. How can a researcher establish if there is a significant difference, say that the distribution of 0's and 1's is closer to an underlying 11111 distribution rather than to a 0101010101 distribution?
This is an incredibly simple question, apologies but a bit confused. Furthermore, how would you implement it with stata? 
Usually doing something like ttest XX, by (YY) works but here there is only one variable?
 A: You can run a Binomial test. Based on your explanation, it sounds like you want a one-sided test. A quick search indicates that this is a bitest in Stata.
A: As Stephen Kolassa has pointed out in his answer, this is tested statistically by the binomial test.  Can I just take the opportunity to add one more point on this, in regard to experimental design.
If you are interested in which beverage tastes better (as opposed to being preferred based on other factors), just surveying people by asking them whether they prefer Coke or Pepsi is a bad design.  It would be much better to conduct blinded taste tests on your participants where you give them two unlabelled drinks (one Coke and one Pepsi) and ask them to taste each of them and tell you which tastes better.  You would randomise the order that the drinks are presented to them, and you would make sure that the taster does not get any information on which is which, other than by taste.  That way, you know that their answer is coming from the taste test.
Incidentally, there is quite a bit of interesting literature on this subject, because Pepsi has tended to win blind taste test experiments, but Coke crushes them anyway.  There is an interesting article in Slate about how Coke won the cola wars despite performing worse in blind taste testing, and there is also an interesting article in Scientific American that touches on this.  If you would like to understand some of the intricacies of this subject, these are nice articles to start with.  One of the main points is that you need to be clear about what it is you are actually testing, and design your experiment appropriately for that goal.  If you are interested in taste then you want to use an experimental design that isolates this factor.  Of course, if you are interested in a broader preference affected by other factors (branding, etc.) then you might prefer to use a straight survey rather than a taste test.
A: +1 to @StephanKolassa for the quick answer.
In case you are partial to coding in R, the binom.test() function in the stats package can be implemented in the same way.  Documentation for binom.test found here.  
A straightforward example with explanation can be found at this link.
