Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: creating new id variable


From   William Buchanan <william@williambuchanan.net>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: creating new id variable
Date   Mon, 27 Aug 2012 19:43:09 -0700

I would also recommend looking at the -egen- command.  If the id variables are stored as strings you can use the -concat- subcommand to join them together, and if they are stored as numbers you can use the -group- subcommand to create a new variable based on the values of the two variables.  Either way, you should definitely read more of the documentation and the resources available online.  

HTH,
Billy

Sent from my iPhone

On Aug 27, 2012, at 19:08, A Muhyidin <cakalie.a@gmail.com> wrote:

> Dear Statalisters,
> 
> I am trying to make a new id based on the two previous id, but so far
> without any luck.
> The new id that I'd like to make should be 4 digits, 2 digits from id1
> and and 2 digits from id2.
> If id2 consists of 1 digit number, I would like to add zero before the
> last number to make new_id as 4 digits.
> Any help would be appreciated.
> 
> 
> |        id1   id2|     new_id
>     |------------|
>  1. |   11     1 |   1101
>  2. |   11     5 |   1105
>  3. |   11     8 |   1108
>  4. |   11     9 |   1109
>  5. |   11    10 |   1110
>     |------------|
>  6. |   11    14 |   1114
>  7. |   11    15 |   1115
>  8. |   11    16 |   1116
>  9. |   11    17 |   1117
> 10. |   11    18 |   1118
>     +------------+
> 
> Thanks.
> 
> Best,
> 
> 
> 
> A Muhyidin
> *
> *   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   |   Site index