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]

Re: st: RE: Detect use of svy: prefix

From   Richard Williams <>
To, <>
Subject   Re: st: RE: Detect use of svy: prefix
Date   Wed, 25 May 2011 17:04:28 -0500

At 11:25 AM 5/25/2011, David Radwin wrote:
It seems to be the case that e(prefix) will include the value "svy" after
running a svy: command. So you could try something like this

. if strpos("`e(prefix)'","svy")==0 error

adding an error number if you care to.

David, I tweaked your idea a bit:

if strpos("`0'","[iw=_")!=0 error 198

Why? As far as I can tell, if svy: has been used, the command line will include "[iw=_" At least I hope so. :) I should try it out a few thousand times to be sure though. Assuming I am right, I can further tweak the code to distinguish between when svy is ok to use and when it isn't. Still not a perfect solution though, because even if I am right, Stata could zap me by making changes in the svy prefix, e.g. using "iweight" instead of "iw" .

Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:   (574)289-5227
EMAIL:  Richard.A.Williams.5@ND.Edu

*   For searches and help try:

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