Announcement

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

  • How to Recode Observations as Ranges

    Hello,

    I am currently using a dataset in which income is a string variable with observations formatted like the following : "From $ 15.001 to $ 20.000". This format is basically unusable as it stands, since I will need to do further calculations with the numbers.

    Is there any way that I can generate a variable in which every observation is a numeric range? For example, an observation might look like this (or something similar, according to STATA formatting): 15.001 - 20.000

    The basic idea is to format the observations in a way in which I would be able to use the ranges to do some calculations (multiplication, regressions, etc). I haven't been able to find any commands that would allow me to do this and I'm not sure if STATA even allows for ranges as observations. Any help would be much appreciated.

  • #2
    I think you will need to do this in a couple of steps with several commands; you will need to set up a categorical variable in Stata and then set up value labels; for example:
    Code:
    gen catincome=1 if income=="From $ 15.001 to $ 20.000"
    with statements for each possible category

    then set up value labels; see
    Code:
    help label
    if you want the categories with different numbers than 1 thru whatever, that is your choice

    you can then easily use this in a regression using factor variable notation; see
    Code:
    help fvvarlist
    I have no idea how, or why, this could be used in "multiplication" (unless you make your category scores equal to the midpoint of each category (note that this will not work for a possible "open" top category

    Comment

    Working...
    X