Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: joining strings


From   Kevin McConeghy <kevinmcconeghy@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: joining strings
Date   Wed, 28 Nov 2012 10:00:10 -0600

Hello users,

I have a dataset with ~2.2 mill obs like so:

obs
id        stringvar    + other variables
1          x
1          y
1          z
2          a
3          d
4          g
4          h

I was trying to combine the stringvar to collapse and make id a unique
key, like so:

id         stringvar
1          xyz
2          a
3          d
4          gh

with the following code:

quietly by id: gen x_ = cond(_N==1,0,_n)
egen x = concat(x_), p(_)
drop x_

reshape wide stringvar, i(id) j(x) string
egen str244 all_stringvar=concat(x1, x2, x3....)

Which worked for one quarter of data, but it takes a lot of computer
power with 1.9 obs and up to 100 unique string var for 1 obs
My computer wont calculate it for the whole dataset because it runs
out of memory

Is there some way to skip the reshape step and join string variables
by specifying the same id?:
egen stringvar_all = concat(stringvar), by id

Thanks for any help,
Kevin
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index