Announcement

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

  • Creating a variable by relative difference of two columns

    Hi,
    I have data on employment duration of employee 1 and 2 measured in months. I want to create a new variable to see whether emlpoyee 1 has been working for longer/shorter compared to employee 2. I tried
    Code:
    difference =abs(emp1-emp2)
    but it doesn't look like what I'm looking for. Is there any way to do this in Stata 14.
    Thanks in advance for your help!


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte(emp1 emp2)
    35 44
    37 45
    32 43
    38  .
    32 43
    27 30
    21 25
    28 38
    38 45
    35 45
    33 44
    23 27
    42 44
    49 50
    42 48
    34 42
    25 31
    40 46
    34 50
    47 56
    21 27
    33 41
    25 29
    24 27
    30 41
    31 32
    15 28
    30 30
    38 43
    43 52
    32 33
    34 48
    47 50
    32 37
    21 20
    36 38
    35 45
    41 53
    35 50
    33 38
    15 17
    41 53
    20 20
    42 61
    29 43
    44 52
    43 47
    33 44
    48 53
    20 23
    37 41
    20 26
    33 41
    37 44
    27 39
    31 45
    27 31
    19 24
    31 43
    22 33
    24 28
    44 65
    34 33
    18 28
    38 46
    34 40
    31 36
    29 32
    20 22
    37 43
    26 29
    28 36
    33 39
    32 45
    48 56
    24 29
    41 47
    37 48
    28 31
    19 26
    28 39
    43  .
    41 46
    47 51
    18 25
    30 35
    26 28
    27 30
    27 28
    17 22
    40 47
    19 26
    20 30
    42 48
    18 25
    48 56
    40 43
    37 52
    23 30
    34 39
    end
    label values v730 V730
    Last edited by Sonnen Blume; 28 Nov 2019, 12:32.
Working...
X