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

st: RE: combining string vars


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: combining string vars
Date   Thu, 3 Jul 2003 17:06:49 +0100

Erica Seiguer
> 
> if i have two string variables, is it possible to combine 
> them? ie, the
> first var is two digits referring to a state (i.e. 44) and 
> the second var is
> 4 digits referring to facility number (i.e. 0010). I want a 
> var to look like
> 440010.

Yes. Basically, + means concatenation 
with strings (i.e. string variables or more generally 
expressions which are or which evaluate to strings)
on either side. 

gen strboth = strvar1 + strvar2 
gen strboth2 = strvar1 + " " + strvar2 

Also check out -egen, concat()-. 

Nick 
n.j.cox@durham.ac.uk 
*
*   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