Announcement

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

  • Making a variable for all subjects but with differents peak exercise loads.

    Dear all
    I
    have these data in stata where all the subjects have different peak exercise loads where I want a variable with the data for each subject max workload results (CO) . So for one patient the latest CO is 12.3 (for workload step 4) but for other is 19 (for workload 19.

    Are the a command making one column with there max workload co?

    Thank you
    M

    randomization_no step_1_co_v2 step_2_load_15_25_v2 step_2_co_v2 step_3_load_30_50_v2 step_3_co_v2 step_4_load_45_75_v2 step_4_co_v2 step_5_load_60_100_v2 step_5_co_v2 step_6_load_75_125_v2 step_6_co_v2 step_7_load_90_150_v2 step_7_co_v2 step_8_load_105_175_v2 step_8_co_v2 step_9_load_120_200_v2 step_9_co_v2 max_load_v2
    81 10.7 25 W 11.9 50 W 11.7 75 W 12.3 75
    82 5.94 25 W 6.89 50 W 8.51 75 W 10 100 W 14.5 125 W 16.2 125
    83 6.63 25 W 7.04 50 W 8.65 75 W 10.7 100 W 13.5 100
    84 6.4 25 W 7.29 50 W 9.42 75 W 10.3 100 W 12 125 W 13
    85 25 W 6.39 50 W 7.49 75 W 9.66 100 W 13 125 W 14.8 125
    86 6.76 25 W 7.69 50 W 9.63 75 W 10.3 100 W 13.6 125 W 13.6 150 W 14 150
    87 10.2 25 W 10 50 W 11.5 75 W 13.4 100 W 14
    88 7.1 25 W 8.38 50 W 9.05 50
    89 9.44 25 W 11.9 50 W 13.9 75 W 14.1 100 W 14.1 125 W 14.9 150 W 17.1 150
    90 4.56 15 W 4.58 15
    91 6.68 25 W 9.67 50 W 10.5 75 W 12.5 100 W 13.5 100
    92 4.49 25 W 5.38 25
    93 5.49 25 W 6.6 50 W 8.81 75 W 11.2 100 W 10.6 100
    94 6.41 25 W 8.19 50 W 10.1 75 W 13.2 100 W 15.8 125 W 16.1 125
    95 5.75 25 W 7.32 50 W 9.21 75 W 10 75
    96 7.32 25 W 9.73 50 W 10.6 75 W 10.1 100 W 12 100
    97 10.1 15 W 10.2 30 W 13.5 45 W 15.2 60 W 14.7 75 W 16.1 75
    98 6.46 25 W 10.1 50 W 11.9 75 W 12.4 100 W 14.9 125 W 17.6 125
    99 4.2 25 W 5.43 50 W 6.35 75 W 6.87 75
    100 6.31 25 W 6.86 50 W 9.54 75 W 10.4 100 W 12.1 125 W 12.7
    101 4.2 25 W 5.76 50 W 7.93 75 W 9.74 75
    102 5.54 25 W 7.29 50 W 8.73 75 W 11.7 100 W 12.5 100
    103 8.71 25 W 8.81 50 W 9.03 75 W 9.59 100 W 13.3 100
    104 3.21 25 W 3.71 50 W 4.78 75 W 5.8 78
    105 6.16 25 W 6.82 50 W 9.14 75 W 9.89 100 W 11.9 100
    106 4.39 25 W 4.79 50 W 6.87 75 W 9.3 100 W 11.8 125 W 14.2 125
    107 6.43 25 W 7.41 50 W 8.32 75 W 9.49 100 W 14.9 125 W 15.6 125
    108 5.31 25 W 5.71 50 W 7.14 75 W 8.87 100 W 9.4 125 W 11.6 125
    109 3.63 25 W 3.87 50 W 3.93 75 W 5.57 100 W 6.47 100
    110 5.67 25 W 7.6 50 W 9.19 50
    111
    112 6.74 25 W 8.45 50 W 10.2 75 W 13.4 100 W 17.2 125 W 15.8 150 W 17.9 150
    113 6.05 25 W 10.2 50 W 10.1 75 W 12.9 100 W 18.3 125 W 18.4 150 W 12.3 175 W 18.6 175
    114 5.81 25 W 7.21 50 W 9.21 50
    115 5.67 25 W 6.13 50 W 7.05 75 W 8.82 75

  • #2
    Code:
    egen max_co = rowmax(step*_co_v2)
    Notes:

    1. In the future, when showing data examples, please use the -dataex- command to do so. If you are running version 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    2. Read -help egen-. You will find many functions there that, like -rowmax()- help with basic data management tasks.

    3. Ultimately, you might be better off using the -reshape- command to put this data into long layout. While the particular task here is easily enough accomplished in the current wide layout, most Stata data management and analysis commands work best, or only, with long data.

    Comment


    • #3
      Dear Clyde

      Thank you, it was the perfect command.
      I will use dataex next time.

      Comment

      Working...
      X