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

st: RE: Programming question.


From   "Steichen, Thomas J." <[email protected]>
To   <[email protected]>
Subject   st: RE: Programming question.
Date   Thu, 18 Aug 2005 09:41:48 -0400

Amadou Bassirou DIALLO writes:

> I want to add to my syntax an option (method)
> which could be mca factor or pca.
> The user could specify all the three or only one,
> but must specify at least one.
> But somehow, I can't figure how to parse that option.
> 
> So my code is :
> 

>  ...
>  tokenize `method'
> /*Here, the only I though of is to parse method and pass 
> arguments one by one*/ if "$_1" == "factor" {
>    I run factor analysis
> }
> if "$_2" == "pca" {
>   pca
> }
> etc...
> end
> 
> By I want the user to be able to specify all the methods he 
> wants. Also, I realized that if factor is not put in premiere 
> instance, no method is used.

Why not have separate options:

  syntax varlist [if] [in] [weight] [, mca pca factor]

Then test that at least 1 is requested:

  if "`mca'`pca'`factor'" == "" {
     di as err " at least one method required"
     exit
  }

  if "`pca'" != "" {
    pca
  }
  etc.

Tom

-----------------------------------------
CONFIDENTIALITY NOTE: This e-mail message, including any attachment(s),
contains information that may be confidential, protected by the attorney-
client or other legal privileges, and/or proprietary non-public
information. If you are not an intended recipient of this message or an
authorized assistant to an intended recipient, please notify the sender by
replying to this message and then delete it from your system. Use,
dissemination, distribution, or reproduction of this message and/or any of
its attachments (if any) by unintended recipients is not authorized and may
be unlawful.


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