Thursday, March 09, 2006
RE: st: creating unique identifier values
This can also easily be modified to meet Richard's comment. For example,
gen x = string(x1) + "_" + string(x2))
is such that "2_11" can be distinguished from "21_1".
Nick Cox > Noting Richard Williams' caveat, and just > focusing on the question, it can also be > done without loops: > > set obs `=26 * 35' > egen x2= seq(), to(35) > egen x1= seq(), block(35) > gen x = real(string(x1) + string(x2)) > > -egen- haters can do it without any interpreted > code: > > set obs `=26 * 35' > gen x1 = ceil(_n/35) > gen x2 = 1 + mod(_n-1, 35) > gen x = real(string(x1) + string(x2)) > > and that could be telescoped further. >
* * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/
Links to this post: