Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: more complicated counting...


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: more complicated counting...
Date   Thu, 17 May 2007 22:42:41 +0100

A small detail, but one that has arisen in various other 
postings recently, to my surprise. 

On Statalist, we are sensitive to the rules of English, 
whatever they are, but where there is a clash the rules 
of Stata take absolute precedence. 

Thus, never write things like 

Gen keepers = 0 

That is just illegal Stata, as "Gen" is not a legal Stata 
command. A reference to it would  probably fool 
very few readers, but nevertheless always write things like 

gen keepers = 0 

Nick 
[email protected] 

Moore, Jesse
 
> Austin, 
> Thanks for your response.  You'll have to forgive my using 
> illegal names
> for variables.  I am new to stata and did not realize that 
> such a beast
> existed.  The variable names I used in my email are different 
> than in my
> dataset, as I was trying to impart more information for the listserv.
> Apparently that backfired!
> 
> I'll try to clarify my question:  Patients are operated on by 
> a surgeon,
> a surgeon may operate at more than one hospital.  If a 
> surgeon operates
> at more than one hospital I want to keep the patients from 
> the hospital
> where the surgeon did the most cases (to preserve as much 
> sample size as
> possible).
> 
> From your response and my own trial and error I came up with the
> following solution:
> Gen keepers=0
> gsort surg -cases
> by surg: replace keep=1 if hospid[_n]!=hospid[1]
> 
> This worked in my dataset beautifully.
> 
> Thanks for the tips on user-written contributions.

*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index