In a given year, an organization has several trip information. Each trip for an organization in a year can be repeated. Below, I have provided the trips for Organization_Year == 1 and Organization_Year == 2. When Organization_Year == 2, the trips do not start from 1 but continue from the last trip of Organization_Year 1.
Within the dataset, there are two date variables, Date1 and Date2. In most cases, these two date variables are the same, although occasionally they differ. The same trip does not have a different Date 1variable. The same trip does not also have a different date2 variable.
My objective is to create two additional trip variables for each organization_year variable based on the Trip Variable. The first variable is a new_Trip1 ordered in descending order of Date1, while the second variable will be another new_Trip2 variable ordered in descending order of Date2.
I have already presented the date in dataex after making it in descending order of date1 variable using (gsort Organization_Year -Date1).
----------------------- copy starting from the next line -----------------------
------------------ copy up to and including the previous line ------------------
Listed 67 out of 67 observations
.
end of do-file
Thank you and looking forward to your suggestions
Within the dataset, there are two date variables, Date1 and Date2. In most cases, these two date variables are the same, although occasionally they differ. The same trip does not have a different Date 1variable. The same trip does not also have a different date2 variable.
My objective is to create two additional trip variables for each organization_year variable based on the Trip Variable. The first variable is a new_Trip1 ordered in descending order of Date1, while the second variable will be another new_Trip2 variable ordered in descending order of Date2.
I have already presented the date in dataex after making it in descending order of date1 variable using (gsort Organization_Year -Date1).
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(Organization_Year Trips) double(Date1 Date2) 1 15 15270 15270 1 9 15267 15267 1 9 15267 15267 1 8 15259 15259 1 8 15259 15259 1 8 15259 15259 1 16 15256 15256 1 16 15256 15256 1 14 15244 15243 1 14 15244 15243 1 13 15135 15135 1 13 15135 15135 1 1 15133 15133 1 1 15133 15133 1 1 15133 15133 1 17 15133 15133 1 1 15133 15133 1 17 15133 15133 1 17 15133 15133 1 17 15133 15133 1 12 15131 15131 1 12 15131 15131 1 12 15131 15131 1 12 15131 15131 1 2 15050 15050 1 5 15034 15034 1 4 15029 15029 1 3 15025 15025 1 11 15004 15004 1 11 15004 15004 1 11 15004 15004 1 11 15004 15004 1 11 15004 15004 1 6 14997 14997 1 6 14997 14997 1 6 14997 14997 1 7 14990 14990 1 7 14990 14990 1 7 14990 14990 1 10 14983 14983 1 10 14983 14983 1 10 14983 14983 1 10 14983 14983 2 24 15289 15289 2 26 15283 15283 2 26 15283 15283 2 26 15283 15283 2 25 15276 15276 2 32 15272 15272 2 32 15272 15272 2 31 15254 15253 2 31 15254 15253 2 33 15250 15250 2 27 15140 15140 2 28 15140 15140 2 29 15140 15140 2 30 15140 15140 2 19 15137 15137 2 18 15137 15137 2 18 15137 15137 2 19 15137 15137 2 19 15137 15137 2 18 15137 15137 2 22 15054 15054 2 21 15045 15045 2 20 15043 15043 2 23 15019 15019 end format %td Date1 format %td Date2
Listed 67 out of 67 observations
.
end of do-file
Thank you and looking forward to your suggestions
Comment