Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: creating new id variable
From
William Buchanan <[email protected]>
To
"[email protected]" <[email protected]>
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 <[email protected]> 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/