Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: ado file help


From   daniel klein <klein.daniel.81@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: ado file help
Date   Tue, 14 Aug 2012 17:45:59 +0200

Tashi,

-syntax- does not look backwards, but offers a convenient way to check
whether what the user specifies are actually valid variable names in
the current dataset. That does not suck at all, once you understand
it. Feel free to specifiy -namelist- instead of -varlist- and do the
checking "by hand" later on, e.g.

pr dd
    vers 12.1
    syntax [namelist] , STARTdate(str) ENDdate(str) BROKERid(numeric)
GRAPHtype(str)

    <load the data>

    if ("`namelist'" == "") loc namelist _all
    cap unab varlist : `namelist'
    if (_rc) {
        <do whatever you want to do, if namelist contains invalid
variable names>
    }
    else {
        <do whatever you want to do if namlist conatains all valid
variable names>
    }
end

Best
Daniel

-- 
in this code, 2 variables are created namely var1 and var2. So, I want
to create a dataset using syntax options, which I did.  I would also
like to have the flexibility of drawing graphs of the variables I want
( say for example tsline var1 or var2 or both)  or list the
variables(say for example list var2 or var2 or both )  for that
matter. What really sucks is syntax's limitation to only look
backward. As I said, I could have syntax statement after creating
dataset( and I am sure that wouldn't be that hard) but for this
particular example, I need to define it before to create datasets on
first place.

Note: I am very careful to not use any abbreviation while posting ):
example for eg.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index