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   Ulrich Kohler <[email protected]>
To   [email protected]
Subject   Re: st: How to merge 2 datasets using 2 unique variables
Date   Tue, 26 Apr 2005 16:33:23 +0200

Robin Newberry wrote:
> >datasets on both variables, then list both in the -merge- command:
> >
> >  . merge ssn adate using ...
>
> Thanks, but I just noticed an issue. In one dataset the Social
> Security Number is in the "standard" format (###-##-####), while in
> the other it's just a set of straight digits (no hyphens). I guess I
> need to remove the hyphens in the one set - how do I do that?

I assume that you want to remove the hyphens, and don't want to replace them 
with spaces. If "ssn" is the variable containing the SSN, then 

. replace ssn = subinstr(ssn,"-","",.)

should do the trick. See -help strfun- for details.

Take care that the ssn variables in both datasets are either "strings" or 
"numbers". Use -tostring- or -destring- to convert your strings to real or 
vice versa. I recommend to use strings. 

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/



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