[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: [programming] syntax syntax

From   "Feiveson, Alan H. (JSC-SK311)" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: [programming] syntax syntax
Date   Fri, 14 Dec 2007 09:34:31 -0600

Nick - 

Yes, I looked at the help and buried way down inside is this cyptic

option_descriptor optional_integer_value

        type                OPname   (capitalization indicates minimal
        type                (integer
        type                # (unless the option is required) 
                              (the default integer value)
        type                )

Reading this, I never would have guessed that a default is required. So
I greatly thank you and Tom and Austin for taking the trouble to reply
to my questions.



-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nick Cox
Sent: Friday, December 14, 2007 9:19 AM
To: [email protected]
Subject: st: RE: [programming] syntax syntax

When -xb1()- takes a real argument and is an optional option then you
must specify a default, e.g. -xb1(real 0)-. 

An equivalent constraint does not bite with a string argument, as an
empty string is the default. 

The second question is answered by specifying 


The online help is very dense, but both points are covered. 

[email protected] 

Feiveson, Alan H. 

I have two questions regarding the syntax of the "syntax"

I've been trying to write a program (effcon.ado) that starts with

syntax [varlist] [if] [in] , confdir(string) level(real) [xb1(string)
n1(string) ]
tokenize `varlist'
local nv: word count `varlist'
di " nv = `nv'"

For some reason, this will work only if the "xb1" option is a string,
but not if I change it to real:

a) output when xb1 is a string in the syntax statement:
. discard

. effcon x1,level(.95)  confdir(L) xb1(xyz) n1(asd)  nv = 1 [it works,

But if I change the "xb1" option to real, I get a syntax error:

b) output when xb1 is real in the syntax statement:
. set trace on

. discard

. effcon x1,level(.95)  confdir(L) xb1(1.234) n1(asd)
-------------- begin effcon ---
- version 9.0
- syntax [varlist] [if] [in] , confdir(string) level(real) [xb1(real)
n1(string) ]
invalid syntax
---------------- end effcon ---

My second question deals with the word count of `varlist'. I want to
have the option of no variables in varlist. But if I don't list any in
my calling statement, `'varlist' is treated as a list of all the
variables in my dataset. I thought I could just count the elements in
`'varlist' and then do something if that count is zero (i.e. if I don't
enter any variables) - but the count comes out 12 (in this case) because
I have 12 variables in my data set. Any other suggestions on how to test
if I entered any variables in my calling statement?


Al Feiveson

2) Example where I enter no variables but `varlist' contains all my
Contains data from temprat.dta
  obs:           100                          
 vars:            12                          13 Dec 2007 08:05
 size:         5,200 (99.9% of memory free)
              storage  display     value
variable name   type   format      label      variable label
R               float  %9.0g                  
C               float  %9.0g                  
xb1             float  %9.0g                  
xb2             float  %9.0g                  
s               float  %9.0g                  
rat             float  %9.0g                  
rat10           float  %9.0g                  
a               float  %9.0g                  
b               float  %9.0g                  
n1              float  %9.0g                  
x1              float  %9.0g                  
x2              float  %9.0g                  
. discard

. set trace on

. effcon ,level(.95)  confdir(L)
-------------- begin effcon ---
- version 9.0
- syntax [varlist] [if] [in] , confdir(string) level(real) [xb1(string)
n1(string) ]
- tokenize `varlist'
= tokenize R C xb1 xb2 s rat rat10 a b n1 x1 x2
- local nv: word count `varlist'
= local nv: word count R C xb1 xb2 s rat rat10 a b n1 x1 x2
- di " nv = `nv'"
= di " nv = 12"
 nv = 12
 [rest omitted]

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index