I would like to count observations of a variable made of observations of other variables which fulfill logical criteria and use it in an assert
statement in order to do some testing of data constraints, e.g.
generate myvar = (var1 == 0 & var2 > 0) | (var1 == 0 & var3b > 0)
assert magiccommand(myvar) == 0
where magiccommand
should be the command or function I'm looking for (doesn't have to be a function).
I tried
count
:help count
doesn't provide any information on how to count observations. Linkage of information in general is very poor.sum()
: doesn't do the job, the graphical output displays the number of observations, but Stata's poor language concept doesn't allow programmatic retrieval of the value, nor does it provide any points of entry for information retrieval in the manual viahelp
.by
: is insufficiently explained in general and seems to be designed too powerful.- I checked confirm conditional statement applies to >0 observations in Stata which is almost the same question as mine, but I'm not sure how I'm supposed to apply the answer to
assert
and still too shocked about the complexity of the command for such a ridiculously easy task. help _n
: "contains the number of the current observation" without a link to an explanation what the current observation is...
I'd be very interested in a way how I could have found out an answer myself because it's very hard to use closed source software which is built on selling expensive books compensating the malious manual.
I have to use Stata
13 on Windows 7.
© Copyright 1996–2014 StataCorp LP
, so what do you mean with the documentation being now open source? - Karl Richter