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   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: How to merge 2 datasets using 2 unique variables
Date   Tue, 26 Apr 2005 16:55:28 +0100

That shouldn't surprise you. -string()- is 
a function, not a command. You normally 
use it within a -generate- or -replace- 
command. 

Also, it appears that you are ignoring 
Uli's excellent advice, which was to 
use -tostring-. 

Nick 
n.j.cox@durham.ac.uk 

Robin Newberry
 
> 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 ...

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index