Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Problems with outtable


From   Roger Newson <[email protected]>
To   [email protected]
Subject   st: RE: Problems with outtable
Date   Fri, 30 Jan 2004 12:39:09 +0000

At 06:55 30/01/04 -0500, Richard Williams wrote:
At 11:50 AM 1/30/2004 +0000, Nick Cox wrote:
Stata is objecting to lines of the form

if <condition> { <action> }

as the braces are no longer allowed
in such single-line statements. I'll send
a version to Kit Baum, the author,
with this fixed.
I thought that if you used the version command, you were supposed to be able to avoid problems like this. Are there known exceptions to this, or was this just an instance where Stata inadvertently failed to maintain backward compatibility?
I myself had problems with this feature many years ago. I think you'll find that StataCorp never intended to make

if <condition> { <action> }

legal in the first place, and the fact that it ever was legal was itself a mistake on their part. (Another mistake of theirs was to include an illegal construct of this nature in the manuals under -[P] if-, which is there to this day at the bottom of Page 218 of the Stata 8 programming manual.)

In Stata syntax, there should always be a statement delimiter between any 2 statementss, and a right brace } is itself a statement. The statement delimiter can be either a newline or a semicolon, depending on whether you set the delimiter by

#delimit cr

or by the alternative

#delimit ;

(See the programming manual under -[P] #delimit-.) In the latter case, you may have a line in the program

if <condition> {; <action> ; };

and in the former case, you must replace the semicolons with newlines, as in

if <condition> {
<action>
}

Which #delimit you choose depends on whether you find it a greater effort to remember the semicolon at the end of every statement or to "comment out" the newline at the end of every non-ultimate line of every multi-line statement.

I hope this helps.

Roger


--
Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
or 020 7848 6605 International +44 20 7848 6605
Email: [email protected]
Website: http://www.kcl-phs.org.uk/rogernewson

Opinions expressed are those of the author, not the institution.

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