Announcement

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

  • generating a variable with a custom transformation

    Hi, I am analyzing auction data with Stata.

    What I would like to do is to generate a variable of equilibrium-bid from a variable called value.

    value includes integers from 1 to 100. And I would like to generate equilibrium-bid from value. Unfortunately, I do not have an analytic form of bidding function. Instead, I have a numerical approximation of the bid function (ex 1-> 1.4, 2-> 1.7, 3-> 2.3, ......). So technically, I can generate equilibrium-bid by typing the following.

    gen equilibrium-bid = 1.4 if value == 1
    replace equilibrium-bid = 1.7 if value == 2
    replace equilibrium-bid = 2.3 if value == 3
    ............
    and so on.

    But the problem is I have 100 types of values, so it will be inefficient to type 100 lines. Is there any ways to do the same job more conveniently?

    Thanks,
    Jinsoo

  • #2
    Using the data editor, create a new data file that contains 100 observations. The first variable is called value and ranges from 1 to 100. Call the second variable equilibrium_bid and type in the corresponding numbers for equilibrium_bid. (Note the _, not -, because - is not legal in a variable name, but _ is.) Save this data set. Let's call it equilibrium_function.dta. Now use your original data set and
    Code:
    merge m:1 value using equilibrium_function

    Comment


    • #3
      Thank you! merge will do the job!!

      Comment

      Working...
      X