Announcement

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

  • Can we fix one observation of a variable and multiply all other observation of another variable with that fixed observation in stata?

    Hi,

    I wanted to fix one observation of a variable and multiply all other observations of another variable with that fixed element. I would then save save each of those product as a separate variable (by generating new variables the numbers of which correspond to the number of observations). Then I'd like to move to the next observation of the first variable and repeat the process.

    For example: my data set looks like this.
    A B C var1 var2 var3 var_n
    1 0 0 =B1*C1 =B1*C2 =B1*C3 =B1*CN
    2 0 0 =B2*C1 =B2*C3 =B2*CN
    3 0 0 =B3*C1 =B3*CN
    4 0 0
    5 0 0
    6 0 0
    7 0 0
    8 0 0
    9 8580 0
    10 8580 0
    11 8580 0
    12 8580 0
    13 5720 0
    14 5720 0
    15 5720 0
    16 5720 0.25
    17 2860 0.5
    18 2860 0.25
    19 2860 0
    20 2860 0
    21 2860 0
    22 2860 0
    23 2860 0
    24 2860 0
    25 1320 0
    27 0 0
    28 0 0
    29 0 0
    30 0 0 B30*CN
    Does anyone know how to solve this?

    Thanks much in advance.
    Ranju

  • #2
    (This is the Mata-specific subforum, you'll probably get more replies if you post in the Stata-specific subforum. Best, S)

    Comment


    • #3
      Great! Thanks.

      Comment

      Working...
      X