Bookmark and Share

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

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

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

From   Nick Cox <>
To   "''" <>
Subject   st: RE: RE: RE: RE: RE: RE: Re: Stata 12: wish list
Date   Tue, 2 Nov 2010 17:33:54 +0000

I thought that "misled" was the past participle of a verb "misle" until I was about 13. Otherwise put, words can be misleading and one can easily be misled into misreading. 


-----Original Message-----
From: [] On Behalf Of Amy Dunbar
Sent: 02 November 2010 17:28
Subject: st: RE: RE: RE: RE: RE: Re: Stata 12: wish list

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

-----Original Message-----
From: [] On Behalf Of Nick Cox
Sent: Tuesday, November 02, 2010 1:23 PM
To: ''
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. 


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:

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