Comments (9)
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:
// 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)
from ftools.
from ftools.
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?
from ftools.
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 unmatched()
does that merge's keep()
doesn't.
Regarding umatch()
it can actually be done through the join
command. I actually wrote fmerge as a wrapper to join (which has a more familiar syntax for me). For instance, suppose you have a panel of consumers (where t
is the year identifier) and want to add some macro data from a dataset (where year
is the year identifier)
With merge
, you do:
rename t year
merge m:1 year using "annual_data", keepusing(gdp inflation)
rename year t
With join
, you do:
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)
from ftools.
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!!
from ftools.
@aghaynes mentioned one which, as far as I can see, join doesn't do and could be potentially useful. The uname
option allows adding a stub to the variable names of using data. This makes it easy to distinguish which variables were pre-existing and which are new, maybe for comparison.
from ftools.
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?
from ftools.
Yes, I agree. Either of these seem fine. stub
seems to be commonly used, but I'd say prefix is more intuitive if you've never heard of it.
from ftools.
For what it's worth prefix
is the pattern used by frget
in Stata 16
from ftools.
Related Issues (20)
- fmerge error HOT 1
- data type following fcollapse HOT 1
- fcollapse with any missing weights returns all missing HOT 1
- fcollapse incorrectly parses negative weights HOT 6
- join: do not copy certain chars
- join: problems with spaces in filepath HOT 1
- fmerge error HOT 4
- error with join HOT 3
- join: error when using labels and key has different name in using
- fmerge overwrites master dataset's xtset HOT 2
- fmerge: 1:1 merge, error 3498, <id1 id2> do not uniquely identify obs. in the master data HOT 5
- Running ftools commands such as `join` can clear mata objects unrelated to ftools HOT 1
- Dict size exceeds Mata limits? HOT 5
- fmerge / join changes using-keys>100 to missing HOT 1
- Treat negative values in verbose(#) as if they were zero instead of positive HOT 1
- join does not clear sortedby macro HOT 6
- Support many to many join HOT 1
- fcollapse issue with double identifier HOT 2
- parallel_map crashes on computers with slow temp folder
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ftools.