Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Variable values within Brackets

    Hi,
    I am trying to generate a new variable call (ID_new) as shown below, from an existing variable in my data set called (ID_orginal). where my new (ID_new) is to be the exact same of the old variable value except that its values are contained between two square Brackets [as shown in bold], and combined with the (ID_1) variable value.

    Here is an example of my data, I created this part manually in excel but could not figure how to do it in stata to run it for my entire data set:
    ID_1 ID_orginal ID_new
    31010011 2 31010011[2]
    11020051 7 11020051[7]
    81030016 1 81030016[1]
    19040016 2 19040016[2]

    thank you
    Last edited by rena jk; 23 Jan 2020, 10:43.

  • #2
    You could use egen, concat() or make up your own concatenation. By and large, the new variable needs to be string.

    Comment


    • #3
      Originally posted by Nick Cox View Post
      You could use egen, concat() or make up your own concatenation. By and large, the new variable needs to be string.
      Thank you Nick, appreciate your guidiance it worked

      Comment

      Working...
      X