Announcement

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

  • How do I generate a new variable that is a ratio of two existing variables?

    Hello:

    I am currently working on class project using the Bureau of Justice Statistics Census 2005. I am investigating the relationship the affects of the racial diversity of full-time security staff and inmate violence. I would like to combine black and Hispanic security staff into a single variable. Then create another variable that is a ratio of black and Hispanics to whites (i.e., BandH:W). I will do repeat the same process for inmates, as well.

    I have created a variable that combines black and hispanic groups for full-time security staff:
    • gen fts_BandH = ft_s_bl + ft_s_hisp
    However, I am running into issues when attempting to create a variable that is a ratio of black and hispanics to whites:
    • gen fts_BandH_W= fts_BandH : ft_s_w
      • Error message reads, " fts_BandH:ft_s_w invalid name"
    I have also conducted a ratio estimation, however, I am uncertain of how to save the output as a new variable and if saving it as a new variable is the correct approach.
    • ratio fts_BandH_w: fts_BandH/ft_s_w
    I have met with the Professor of this course and given the objectives of the class, he said creating these ratio variables would be sufficient for the final project. But given it is the end of the term, he is extremely busy and slightly unresponsive. I will appreciate all your help with this!

    Cheers


  • #2
    I don't know why you are using colons. How about something like

    gen xyratio = x/y
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    StataNow Version: 19.5 MP (2 processor)

    EMAIL: [email protected]
    WWW: https://www3.nd.edu/~rwilliam

    Comment


    • #3
      Thank you, Mr. Williams.

      Comment

      Working...
      X