Hmm, actually, perhaps I should have been more clear on what I am doing
here. I am not actually using the values of the variable <aRate> in
these statements. The basic idea is I want to run essentially the same
procedure several times on different variables. There are style-type
things I want to change depending on what that variable is (i.e. title
on graph), so I write conditions to differentiate between the relevant
variable. So, a snipped version of my program would look like this:
program test
...
if `1'==aRate {
local title = "Abortion rate"
}
if `1'==bRate {
local title = "Birth rate"
}
This is not actually an issue of how -if- works; it relates to how
Stata passes arguments to programs. The first argument to the program
is passed in local macro 1. If it is a string -- such as a variable
name -- then you can use the contents of local macro 1, that is, `1',
in a command where you want that variable name (such as 'summarize'
below). But if you want to examine the variable name and compare it to
a string, you must treat the contents of local macro 1 as a string,
that is, "`1'", which can be compared to a string "aRate". If the item
on the right side above is not quoted, it is not the string aRate; it
is a reference to the first observation of the variable aRate. If both
aRate and bRate happened to have the same first observation, the result
of your program would be unpredictable. A reliable form of this code
is: