-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding update / replace to fmerge #19
Comments
Yes. It might involve a bit of Mata work, but I'm a bit pressed on time for the next month or so, so can't promise any update. For reference (in case you want to try, or maybe for future me), I think it would involve changing line 381:
Instead of raising an error if the variable exists, when the -update- option is on, you would have to create a tempvar ( Then, after the Mata code finished running, something like |
Thanks for the explanation Sergio. It's nothing urgent, just something that
I stumble upon every once in a while. Maybe I can use your hint to practice
my Stata coding;-)
2018-02-14 12:08 GMT+01:00 Sergio Correia <[email protected]>:
… Yes. It might involve a bit of Mata work, but I'm a bit pressed on time
for the next month or so, so can't promise any update.
For reference (in case you want to try, or maybe for future me), I think
it would involve changing line 381
<https://github.com/sergiocorreia/ftools/blob/master/src/join.ado#381>:
// Check that variables don't exist yet
msg = "{err}merge: variable %s already exists in master dataset\n"
for (i=1; i<=cols(deck); i++) {
var = deck[i]
if (_st_varindex(var) != .) {
printf(msg, var)
exit(108)
}
}
Instead of raising an error if the variable exists, when the -update-
option is on, you would have to create a tempvar (st_tempvar()?) and then
replace row i of varnames_num.
Then, after the Mata code finished running, something like replace
original_var = tempvar if mi(original_var)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#19 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AN3iDvtlGqVk2_79jyRMsvYiHTjr6yqVks5tUr6TgaJpZM4SFGbA>
.
--
Felix Holub
|
mmerge has some really useful options (e.g. unmatched [unmatched observations to keep - none, both, master, using], umatch [for the case that variables in using are named different to master], uname [add a stuf to variables in using]) Is there any intent to add additional features to fmerge? |
Hi Alan, Can you explain a bit more what these options do? I installed mmerge from SSC but I'm not entirely sure of what Regarding With rename t year
merge m:1 year using "annual_data", keepusing(gdp inflation)
rename year t With join gdp inflation, from("annual_data") by(t=year) (Note how the join syntax looks more like the collapse() one, and is more explicit about which variables get added) |
Hi Sergio, Ignore my message. You're completely correct - it's all possible with the other options. (the main advantage to mmerge is that its a bit more verbose in it's reporting) I wasn't aware of join... I think i'll be looking into that a bit more - i have some quite large datasets which take merge/mmerge a long time to combine... Thanks!! |
@aghaynes mentioned one which, as far as I can see, join doesn't do and could be potentially useful. The |
Agree, that should be useful and simple to implement. That said, uname() doesn't seem like an esy-to-remember option, so maybe stub(), prefix() or sth like that? |
Yes, I agree. Either of these seem fine. |
For what it's worth |
Would it be possible to extend
fmerge
to allow forupdate
orreplace
?The text was updated successfully, but these errors were encountered: