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: Create a variable equal to the first part of another variable
From
[email protected]
To
"[email protected]" <[email protected]>
Subject
Re: st: Create a variable equal to the first part of another variable
Date
Sat, 13 Jul 2013 17:11:27 +0100
Use the -substr()- function.
. gen holder = substr(id, 1, 2)
. gen subsid = substr(id, -2,2)
Nick
[email protected]
On 13 Jul 2013, at 15:31, Mario Jose <[email protected]> wrote:
>
> I have a database where the ID is like this AT9898_DE. This specific
> observation is a subsidiary located in the country DE owned by the
> shareholder 9898 located in the country AT. I would like to create two
> variables: one consisting the country of the sharehodler (AT in the
> example) and another equal to the country of the subsidiary (DE).
>
> I would be grateful for suggestions on how to generate from the ID
> variable these two variables. In the end I would have my
> observations/databse like this:
>
> ID Share_country Subs_country
> AT9898_DE AT DE
> PL9769_CZ PL CZ
> .... . ... ...
>
>
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/