Re: st: Re: calculating proportions

I'm not sure how well Ekaterina knows the characteristics of local macros...

Maybe at this point it helps to say that a local macro which is defined by execution of a
.do-file stops to exist after the .do-file is finished.

If you (Ekaterina) are unsure what I mean, try the following:
1. open the dofile editor, write the following two lines and execute them
local our_test_macro "defined interactively"
dis "The macro our_test_macro contains: `our_test_macro'"
2. Now go to the command line and type
dis "The macro our_test_macro contains: `our_test_macro'"
Best
Oliver
Am 21.02.2012 19:31, schrieb Nick Cox:

No, that's not what I said. It's the opposite, if anything.
In more general terms: we can't comment on code that you don't show
us. Your previous mail could be read as implying that there was a
problem with the code using local macros posted by others. My point is
that there wasn't a problem of that kind. If there was a problem with
local macros, it lay in your translation of the code.
However, various other questions remain up in the air. The code you
are using loops over observations. It is evident from looking at the
code for -relrank- (SSC) that no such approach is necessary, but if
your problem is solved you may not mind about that, but I wouldn't
want this thread to fade away without making that point.
Nick
On Tue, Feb 21, 2012 at 6:20 PM, Ekaterina Hertog
<ekaterina.hertog@sociology.ox.ac.uk> wrote:

Dear Nick,
thanks a lot for the pointer.
I must have had N_female defined earlier. Once I dropped all macros, it
worked,
Ekaterina
On 21/02/2012 17:33, Nick Cox wrote:

There are various possible reasons for a problem here with what
Ekaterina did, including
1. No local macro N_female was defined by her earlier.
2. One such was defined by her but is not visible to Stata at that point.
The use of local macros looks fine in the code posted by Pathmes and
Oliver.
Nicl
On Tue, Feb 21, 2012 at 5:22 PM, Ekaterina Hertog
<ekaterina.hertog@sociology.ox.ac.uk> wrote:

Dear Pathmes and Oliver,
thanks a lot, great code and it solves my problems! And I learned more
than
3 things from it
Just a small hitch:
converting numbers to proportions syntax:
gen fap=fa/`N_female'
gives an error message: 'invalid syntax'.
I went around it by creating a variable which is a constant and equals a
total number of women in the population and using it instead of the local
macro. I clumsy way to do it.
katya
On 21/02/2012 16:45, Pathmeswaran wrote: