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

st: RE: RE: combining string vars


From   "Sayer, Bryan" <BSayer@s-3.com>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: combining string vars
Date   Thu, 3 Jul 2003 12:15:03 -0400

In addition, I advise verifying the leading characters, particularly in the
second (and any subsequent) variables.  You want to make sure that such
values as "0010" and "  10" are always the same or are always different, as
appropriate.  Sometimes frequencies on a position by position basis are
helpful.

Bryan Sayer
Statistician, SSS Inc.
bsayer@s-3.com

-----Original Message-----
From: Nick Cox [mailto:n.j.cox@durham.ac.uk] 
Sent: Thursday, July 03, 2003 12:07 PM
To: statalist@hsphsun2.harvard.edu
Subject: st: RE: combining string vars


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