Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: RE: RE: RE: RE: Re: Stata 12: wish list


From   Amy Dunbar <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: RE: RE: RE: RE: Re: Stata 12: wish list
Date   Tue, 2 Nov 2010 17:28:07 +0000

Thank you, Nick!  I simply never saw "touse" as to use.  

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: Tuesday, November 02, 2010 1:23 PM
To: '[email protected]'
Subject: st: RE: RE: RE: RE: Re: Stata 12: wish list

What you may have seen is something like 

marksample touse 

... if `touse' 

This is similar in spirit but not identical:

1. -marksample- automatically marks observations as 1 or 0, to use or not to use, those values being put in a temporary variable, conventionally `touse', that takes account of any prior -if-, -in-, weights and missings consistently with a previous -syntax- statement. 

2. The example with a -touse- variable was just my own code and is not as versatile. You'd also need to take account of any -if- or -in- restrictions and zero weights. 

Nick 
[email protected] 

Amy Dunbar

Thanks for the ranking code, Nick.  I frequently forget that missing vars are still included as the largest.  And now I finally understand the "touse" code that I have seen so frequently in sample code.  Awesome!

Nick Cox

I see main three points arising here. 

1. None of this is trivially easy, even if what you want is provided in the software and well documented. 

2. Whatever StataCorp do, it's not going to get much easier, unless exceptionally their defaults on everything happen to match exactly your choices. Whatever StataCorp do, the consequence is going to be lots of handles to tweak, and mastering that won't be trivial either. I am still getting to grips with Stata graphics, which I have used just about every working day for almost 20 years. Tables, or reporting, is about the same size of beast. 

3. What I see here is positive: You care about well-designed tables and put a lot of work into this code. Next time, not everything will be different and you can steal from what you learned. 

On a detail: if ranking lots of variables, watch out for missing values. Safer code looks like this:

gen touse = !missing(a, b, c)

foreach v of var a b c { 
	egen rank_`v' = rank(`v') if touse 
}

That way, missing values are excluded systematically across a varlist. 


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index