On Wed, 27 Nov 2002, Nick Cox wrote:
> I am still not clear whether -x- and -y- are variables,
Yup, x and y are variables with values for each observation in the data
set.
> and whether this all -- in Some Alternative
> Software -- is tacitly looping over
> observations. (In my case, please assume
> complete ignorance of SAS.)
In SAS (and dBase or SPSS, e.g.), these commands are evaluated for each
observation. In such a structure, once a true condition is met,
subsequent conditions are skipped. Say I want to assign grades to my
students' percentage scores. In SAS I could write
if score > 90 then grade='A';
else if score > 80 then grade='B';
else if score > 70 then grade='C';
else if score > 60 then grade='D';
SAS will assign the appropriate grade to the first condition that is true,
then skip the following conditions in the structure. (This is also true
of other database management languages I've used such as dBase.) This is
why I find it more efficient and less cumbersome than writing the complete
condition for a series of "if ... then"s when every one will be evaluated.
>
> I will also add that I don't find often myself
> wanting to use completely different
> commands for different subsets of a variable.
Certainly true. Nevertheles, I frequently need to write code for
psychiatric diagnostic categories. This is an area where different
subconditions will definitely come up.
I think this is steering dangerouly close to "how do you do it in SAS"
talk, but I did want to illustrate one way that I find Stata less easy to
use than SAS.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/