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

Re: AW: st: Re: Pass Integers to Program

From   Maarten buis <>
Subject   Re: AW: st: Re: Pass Integers to Program
Date   Mon, 18 Feb 2008 09:56:49 +0000 (GMT)

--- Martin Weiss <> wrote:
> thanxx for the advice but what goes for the dots in "syntax...,
> values"? I really cannot get this to work, everytime I try it, I get
> error codes r(197) and r(198)...

... could be a lot of things described in -help syntax-, and since we
did not know what kind of program you were writing we just left that
open by typing ... It could be nothing at all, but often it is
something like this:

syntax varlist [if] [in] [fw aw pw] ,                   ///
       values(numlist min=6 max=6 >0 <50 sort integer) 

In which case someone must enter a list variables and your list of 6
integers, and one can use -if- -in- and weights (fweights, aweights, or
pweights). If you want to allow for -if- and -in-, it is useful to take
a look at -help mark-.

If All you want is to pass the six integers, you can type:

syntax , values(numlist min=6 max=6 >0 <50 sort integer) 

The example below illustrates some of the useful features of -syntax-
in a working example.

Hope this helps,

*--------------- begin example -------------------
capture program drop foo
program define foo
      syntax varlist [if] [in] [aw],                  ///
      VALues(numlist min=6 max=6 >0 <50 sort integer) ///
      [                                               ///
      red                                             ///

      local wgt "[`weight'`exp']"

      marksample touse
      sum `varlist' if `touse' `wgt'

      di _n as txt "the values specified in the option values are:"
      if "`red'" == "" {
            di as result "`values'"
      else {
            di as err "`values'"

sysuse auto, clear
foo mpg if foreign==1 [aw=weight] , val( 1 4 5 2 3 9)
foo mpg , val( 1 4 5 2 3 9) red
*----------------- end example ------------------------
(For more on how to use examples I sent to the Statalist, see )

Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

Sent from Yahoo! Mail - a smarter inbox

*   For searches and help try:

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