[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: multiple merging
Abhimanyu Arora <email@example.com>
Re: st: multiple merging
Tue, 3 Apr 2012 12:26:02 +0200
Thanks very much indeed. Helps clear my understanding both of
-gettoken- and the use of compound double quotes.
Even as I await Ryan Knight's reply with regard to SSC's -mergeall-, I
was trying using Mike M Mitchell's -nmerge- (the -which- command
doesn't seem to display the version of the do file).
The use of nmerge requires the file names in its syntax (simply
separated by spaces, hence the reason for using the extended macro fcn
clean—but error both with and without this)
After the use of gettoken I get the file names but each in double
quotes. Say the macro files contains the strings "file1.dta"
Assume we start with file0 (the one to which others will merge)
. nmerge date using `"`files4'"'
One or more filenames after 'using' required
(no error though)
"file1" "file2"....and so on
local files2 : list clean files
. nmerge date using `"`files3'"'
'file2' found where nothing expected
file1 file2... and so on
Not able to understand why this error. I thought the second option
should work out but don't know what's blocking.
On Tue, Apr 3, 2012 at 9:48 AM, Nick Cox <firstname.lastname@example.org> wrote:
> 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
> <email@example.com> 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
>> 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
> * 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/
* For searches and help try: