Nick
Many thanks for your suggestions.
After much experimenting, I would add "bind" to the gettoken statement to avoid any problems parsing functions that contain commas (this seems to be a very useful option I had not come across before).
Otherwise, this is pretty much what I have ended up with (but a little more complicated to split off the name from the beginning, as this turns out to be important for the real program). Bundling if and in together has saved a lot of work though. I also like the idea of using -syntax- to parse the rest once the dodgy bits have been removed - very handy.
David
Nick Cox:
> No, that first route is unnecessary. How about
>
> program foo
> gettoken data 0 : 0, parse(",")
> syntax [, * ]
> use `data', clear
> count
> ...
> end
>
> That way, any -if- or -in- are just bundled within `data'.
*
* 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/