Hi everyone,
I would like to compute a variable based on several conditions, and I don't know how to proceed please.
Basically, I have to compute a new variable that depends on if a zone is a "s.e.r zone" or not. It depends also on time (-interlude- variable).
I want to compute a new variable, if interlude is not missing and if the zone is s.e.r.
Here is a dataex example:
The code computed to have -interlude- was:
The multiple conditions are a price table as follows for blue_slots:
The new variable name should be something like "blue_parking_prices".
Could anyone give me a solution please? I have been stuck for a while now.
Thank you very much for your help.
Best,
Michael
I would like to compute a variable based on several conditions, and I don't know how to proceed please.
Basically, I have to compute a new variable that depends on if a zone is a "s.e.r zone" or not. It depends also on time (-interlude- variable).
I want to compute a new variable, if interlude is not missing and if the zone is s.e.r.
Here is a dataex example:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input double(parking_slots blue_slots) byte dest_zona_ser float interlude . . 0 . . . 0 315 357 . 1 . . . 0 210 357 . 1 . . . 0 90 . . 0 . . . 0 270 . . 0 120 . . 0 220 . . 0 . . . 0 120 . . 0 120 . . 0 150 . . 0 . . . 0 571 4553 806 1 . . . 0 60 . . 0 . . . 0 180 . . 0 . . . 0 360 . . 0 . . . 0 510 357 . 1 . . . 0 220 . . 0 . . . 0 105 . . 0 517 . . 0 47 2530 353 1 . 2530 353 1 40 2530 353 1 . 2530 353 1 40 3111 441 1 . 2348 204 1 118 2348 204 1 . 2348 204 1 30 2934 414 1 . 2348 204 1 600 . . 0 . 2348 204 1 480 5887 1452 1 . 2438 568 1 90 2035 370 1 . 1925 416 1 78 1925 416 1 325 1925 416 1 85 1925 416 1 . 1925 416 1 0 1925 416 1 . 1925 416 1 110 1925 416 1 . 1925 416 1 0 1925 416 1 320 1925 416 1 0 1925 416 1 440 1925 416 1 0 2438 568 1 . 1925 416 1 419 2438 568 1 89 1925 416 1 329 2982 676 1 . 1925 416 1 310 3238 531 1 . 2934 414 1 . 2934 414 1 . 2934 414 1 510 4361 871 1 . 2934 414 1 330 5001 872 1 . 2934 414 1 360 . . 0 . . . 0 . . . 0 0 2934 414 1 658 . . 0 . . . 0 480 2934 414 1 0 5887 1452 1 . 2934 414 1 400 646 . 1 . . . 0 120 . . 0 . . . 0 90 3310 817 1 . . . 0 555 3310 817 1 . . . 0 0 . . 0 0 . . 0 280 3310 817 1 200 . . 0 0 . . 0 0 . . 0 270 2476 372 1 . . . 0 600 . . 0 . . . 0 324 . . 0 105 end label values dest_zona_ser dest_zonaser label def dest_zonaser 0 "outside s.e.r zone (destin.)", modify label def dest_zonaser 1 "s.e.r zone (destin.)", modify
Code:
by individ_ID (start_time), sort: gen interlude = /// clockdiff(end_time[_n-1], start_time, "m") if _n > 1
Minutes | € |
5 | 0.05 |
9 < x < 13 | 0.10 |
13 < x < 16, and so on... | 0.15 |
16 | 0.20 |
20 | 0.25 |
23 | 0.30 |
27 | 0.35 |
30 | 0.40 |
32 | 0.45 |
34 | 0.50 |
36 | 0.55 |
39 | 0.60 |
41 | 0.65 |
43 | 0.70 |
45 | 0.75 |
47 | 0.80 |
49 | 0.85 |
51 | 0.90 |
54 | 0.95 |
56 | 1.00 |
58 | 1.05 |
60 | 1.10 |
63 | 1.15 |
65 | 1.20 |
68 | 1.25 |
70 | 1.30 |
73 | 1.35 |
75 | 1.40 |
... | ... |
Could anyone give me a solution please? I have been stuck for a while now.
Thank you very much for your help.
Best,
Michael
Comment