Announcement

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

  • Define value label tand conver it to from a string variable to a numeric one

    Hello,

    My name is Christian and I am just beginning as a user of STATA. My question might be a bit silly, however I really need your help since I got stuck and I'm just learning this software. Well, I have a database where "a2" is a numeric variable that every observation such as Cordoba has a value of 4, Buenos Aires a value of 1 and so on. I need to assign a different value to each observation, therefore I created a new variable "ciudad". This new variable is a string variable and now I want to assign to these variable's observations different values, such as for Buenos Aires 9, Cordoba 10, Mendoza 11, etc.


    Click image for larger version

Name:	doubt Stata.jpg
Views:	1
Size:	35.5 KB
ID:	1482951


    Once I got that done, I will drop "a2" because I need to append more data bases to this one with the same variables but with different scenarios and when I do it, the values overlap. For example, this data base is Argentina and when I append Bolivia, the values of "a2" overlap and the Bolivian cities such a La Paz, Sucre, etc that have the same values such as 4, 1, etc automatically are converted to Buenos Aires, Cordoba, etc adopting the values of the Argentinian Database.

    How can I do it?

    Thanks and kind regards.
    Christian Rojas

  • #2
    Christian:
    I would start off with imposing progressive -id- in the databases to be appended.
    Let's assume that you have only two databases (Argentina and Bolivia), composed of 50 observations each.
    Let's start from Argentina:
    Code:
    g id=_n
    Let's consider Bolivia then:
    Code:
    g id=_n+50
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment

    Working...
    X