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

From |
Jean-Benoit Hardouin <jean-benoit.hardouin@club-internet.fr> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: programs with options |

Date |
Fri, 11 Jul 2003 17:42:31 +0200 |

This is perfect, Thank you Jean-Benoit Hardouin On Fri, 11 Jul 2003 11:26:39 -0400, David Kantor <dkantor@jhu.edu> wrote:

To Jean-Benoit Hardouin:

You are referring to `1', `2', `3', etc., which are just the non-blank textual segments of the command line (after the command name). Thus, the final one (`2' in your examples) may include the comma if there is no space after it in the command line.

These are not the same as the elements of the varlist -- until you - tokenize `varlist'-.

So one solution is to put

tokenize `varlist'

into your program, before the `forvalues-statement. But a better way to do this would be...

foreach var of local varlist {

di "`var'"

}

(And you won't need `nbitems'.)

I hope this helps.

-- David

At 05:06 PM 7/11/2003 +0200, you wrote:

See for example program define testop syntax varlist(min=2 numeric) [,option1 option2] local nbitems : word count `varlist' forvalues i=1/`nbitems' { di "``i''" } end .testop var1 var2 ,option1 var1 var2 .testop var1 var2, option1 var1 var2, .testop var1 var2,option1 var1 var2,option1 [...]David Kantor Institute for Policy Studies Johns Hopkins University dkantor@jhu.edu 410-516-5404 * * 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/

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

**References**:**st: RE: programs with options***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**Re: st: RE: programs with options***From:*David Kantor <dkantor@jhu.edu>

- Prev by Date:
**RE: st: RE: programs with options** - Next by Date:
**st: Re: memory management in Win2000** - Previous by thread:
**Re: st: RE: programs with options** - Next by thread:
**RE: st: RE: programs with options** - Index(es):

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