Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: multiple merging

From   Nick Cox <>
Subject   Re: st: multiple merging
Date   Tue, 3 Apr 2012 08:48:29 +0100

Your use of -gettoken- is quite illegal. -gettoken- is perhaps most
often used in this form

 gettoken emname1 emname2 : emname3

in which the -emname*- are extended macronames. Focus on the "names":
you are feeding -gettoken- with macro contents as the macro
_reference_ `r(files)' will get expanded by Stata before -gettoken-
sees it.

Nor will r(files) be acceptable to -gettoken-.

This is an example of will work:

fs <whatever>
local files `" `r(files)' "'
gettoken first files : files

In your case the -local- command may be enough. There is no need to
clean up the " " as they are there for a purpose, to bind names with

-fs- is from SSC.


On Mon, Apr 2, 2012 at 11:22 PM, Abhimanyu Arora
<> wrote:

> I have datasets which I need to merge into a single file. All files
> have a (string) variable that uniquely identifies observations in the
> files.
> There are two user-written commands I found in the SSC—mergeall (Ryan
> Knight) and nmerge(Michael N. Mitchell).
> I am facing problems with both.
> In the first case I get a type mismatch error even though I specify
> the string option with force
> In the second case I am unable to get my file names (except the first
> file) in a macro.  I used fs(Nick Cox) get the file names in r(files).
> Next I type in  gettoken first `r(files)' : `r(files)'
> That shows the following error
> _"filename1.dta invalid name
> I tried using extended macro function to clean up the quotes but to no
> avail.

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index