Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | jpitblado@stata.com (Jeff Pitblado, StataCorp LP) |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: strip factor variable operators? |
Date | Tue, 13 Aug 2013 22:39:14 -0500 |
Stas Kolenikov <skolenik@gmail.com> asks how to remove all time-series and factor variables opterators from a varlist specfication: > is there a simple way to strip out the time series and factor variable > operators? I have a list of regressors with all sorts of stuff like > -i.foreign ib3.rep78 c.price##c.price-, and I want to produce a list > that is cleaned off the prefixes, just -foreign rep78 price-. Is there > a standard parser, or an extended macro function, to do this? I can > take the whole list, -gettoken, parse(".")- each term and strip the > part before the dot, if there's any. But this seems like a relatively > mundane task that must be doable with some official Stata tools. Nick Cox pointed out that -tsrevar- was a start. Stas can use the -fvrevar- command to do this. Here is an example: ***** BEGIN: . sysuse auto (1978 Automobile Data) . fvrevar i.foreign ib3.rep78 c.price##c.price, list . return list macros: r(varlist) : "price foreign rep78" ***** END: --Jeff jpitblado@stata.com * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/