Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: How to merge 2 datasets using 2 unique variables


From   Robin Newberry <[email protected]>
To   [email protected]
Subject   Re: st: How to merge 2 datasets using 2 unique variables
Date   Tue, 26 Apr 2005 11:42:06 -0400

When I try to convert one set of SSN to strings ("string(v14)") I get an "unrecognized command: string" error.

I went back to re-import the data (comma delimited file, all fields enclosed in quotes), but for some reason it imports as a number even though the in the originating file it's "#########".




Robin Newberry wrote:
 >  I recommend to use strings.

 Hmmmm. OK then - how do I put the hyphens into the non-hyphenated string?
No, no. Don't put hyphens into the numbers. Just tread the numbers as strings.
In your non-hyphenated dataset type something like

. ren ssn ssnreal
. destring ssnreal, generate(ssn)
. sort ssn
. save foo, replace

and than merge.

The reason for my recommendation, btw is, that numbers with many digits like
the SSN, can get obscured by the storage-type "float". I generally use
string-variables for unique-identifiers therefore ...

uli


--
[email protected]
+49 (030) 25491-361


*
*   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/

--
Robin
--------------------------------------------------------------
W. Robert Newberry, IV CIH, CHMM
Chief Environmental Health and Safety Officer
Clemson University

[email protected]  [email protected]
http://ehs.clemson.edu/
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index