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: c(mode) with console Stata on OS X

From   "William Gould, StataCorp LP" <>
Subject   Re: st: c(mode) with console Stata on OS X
Date   Mon, 02 May 2011 13:29:12 -0500

Concerning Mac OS X, Phil Schumm <> wrote, 

> Today I fired up an old tool chain that threw an error because c(mode)  
> doesn't seem to exist under console Stata on OS X (and therefore code  
> that uses this to detect whether Stata is running in batch mode didn't  
> work).  

It appears that Phil has found a bug, and not just on the Mac.  I just
observed exactly what Phil reports on a Linux box, and it appears to 
me that the bug has been there for years.

Stata originally had $S_MODE.  The global macro contained nothing (did
not exist), or contained "batch" if Stata was running in batch mode.
Originally, only console versions of Stata could not run in batch mode.
Over the years, GUI versions of Stata learned how to run in batch mode
and, separately, we introduced c().

The current state of affairs is

     1.  All Stata's have $S_MODE that will contain "batch" if running in 
         batch mode.

     2.  GUI versions have c(mode), too.

     3.  Documentation was recast as if c(mode) replaced $S_MODE.

Our intent (I'm guessing based on our records) was that all Stata's
support c(mode), but we made a mistake and never noticed that they
didn't.  We here at StataCorp seem to be using $S_MODE, mainly because
we remember better than anyone else older syntax, and we just never
adjusted.  Meanwhile, no one outside of StataCorp found the bug until now.

So we will fix it, but we are not going to rush.  In the meantime, 
I recommend using $S_MODE.  It works today, and it will work tomorrow.
To determine if you are running in batch mode, code

	if ("$S_MODE"=="batch") ....

to determine if you not running batch, code

	if ("$S_MODE"=="") ....

That works on all platforms and will continue to work (and be undocumented).

-- Bill
*   For searches and help try:

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