Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: How to append two columns


From   John Ataguba <johnataguba@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How to append two columns
Date   Thu, 4 Sep 2008 12:36:44 +0000 (GMT)

Thanks Johannes and Ashim.  The suggestions were great.  I thought there could be a command to just do this without going through manipulations.

Regards

John

--- On Thu, 4/9/08, Johannes Geyer <JGeyer@diw.de> wrote:

> From: Johannes Geyer <JGeyer@diw.de>
> Subject: Re: st: How to append two columns
> To: statalist@hsphsun2.harvard.edu
> Date: Thursday, 4 September, 2008, 12:53 PM
> You could generate strings from your numeric variables,
> add them together and convert the string back to numeric:
> 
> *******************
> clear
> set obs 10
> gen x = _n * 1000
> gen y = _n
> 
> tostring x, generate(a)
> tostring y, generate(b)
> gen z = a + b
> destring z, replace
> 
> ******************************
> 
> Johannes
> 
> 
> owner-statalist@hsphsun2.harvard.edu schrieb am 04/09/2008
> 11:36:48:
> 
> > A crude way would be to multiply the 1st column by 10
> and add the 2nd
> > column to it ?
> > 
> > Ashim
> > 
> > On Thu, Sep 4, 2008 at 3:03 PM, John Ataguba
> <johnataguba@yahoo.co.uk> 
> wrote:
> > > Dear members,
> > >
> > > I am trying to append two colums in stata and I
> was wondering if 
> > this is possible.  Basically I have data in the
> following way
> > >
> > > UQNo           PersonNo
> > > 100012          1
> > > 100012          2
> > > 100012          3
> > > 100024          1
> > > 100024          2
> > > 100019          1
> > > 100019          2
> > > 100019          3
> > > 100055          1
> > > 100075          1
> > > 100075          2
> > >
> > > And I want to generate a new variable that will
> look like
> > >
> > > UQNoP
> > > 1000121
> > > 1000122
> > > 1000123
> > > 1000241
> > > 1000242
> > > 1000191
> > > 1000192
> > > 1000193
> > > 1000551
> > > 1000751
> > > 1000752
> > >
> > > Any suggestion will be appreciated.
> > >
> > > Regards
> > > John
> > >
> > >
> > >
> > >
> > > *
> > > *   For searches and help try:
> > > *   http://www.stata.com/help.cgi?search
> > > *   http://www.stata.com/support/statalist/faq
> > > *   http://www.ats.ucla.edu/stat/stata/
> > >
> > *
> > *   For searches and help try:
> > *   http://www.stata.com/help.cgi?search
> > *   http://www.stata.com/support/statalist/faq
> > *   http://www.ats.ucla.edu/stat/stata/
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/


      

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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