Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: macro list parsing
From
Jakob Petersen <[email protected]>
To
[email protected]
Subject
Re: st: macro list parsing
Date
Tue, 17 Jan 2012 12:49:19 +0000
Thanks to Maarten and Nick,
The following worked and would deal with both temp and any other foreign
vars
*********************************************
sysuse autornd.dta,clear
unab alist : *
sysuse auto.dta,clear
unab blist : *
local thelist : list alist & blist
d
order `thelist',after(turn)
d
*********************************************
Jakob
On 17/01/2012 11:37, Nick Cox wrote:
Alternatively, you can just flush temporary variables before issuing
the -ds- call:
drop __*
Using -ds- is a little roundabout here, although it works fine. See also
SJ-10-3 dm0051 . . . Tip 91: Putting unabbreviated varlists into local macros
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
Q3/10 SJ 10(3):503--504 (no commands)
tip on interactively using unab to expand a varlist and
place the resulting unabbreviated varlist in a local macro
Nick
On Tue, Jan 17, 2012 at 11:28 AM, Maarten Buis<[email protected]> wrote:
On Tue, Jan 17, 2012 at 12:10 PM, Jakob Petersen<[email protected]> wrote:
I am trying order the variables on one file according to the order on
another file.
This works well on the example datasets, e.g.
*********************************************
sysuse autornd.dta,clear
ds
local orderlist `r(varlist)'
sysuse auto.dta,clear
d
order `orderlist',after(turn)
d
*********************************************
But returns an error code when I attempt the same on my own data:
variable __000005 not found
r(111);
It means that you have a temporary variable in your original file, and
this variable obviously does not exist in the other files. You can
exclude temporary variables from the local orderlist by typing
ds __*, not
local orderlist `r(varlist)'
The trick is that temporary variables have, for as long as they exist,
names that start with two underscores.
*
* 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/
--
Kind regards,
Jakob
/*
Jakob Petersen
Institute for Social and Economic Research (ISER)
University of Essex, Colchester, Essex CO4 3SQ, UK
T: +44 (01206) 873683
E: [email protected]
www.iser.essex.ac.uk
Understanding Society User Support
http://data.understandingsociety.org.uk/documentation/support
*/
*
* 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/