Hello Stata users;
I have this code:
As you can see, the third variable "Mois" is a time variable, yet its type is int, which means that it doesn't show as a "month-year" variable in that data example already, and I can apply an "if" command on it to generate another variable.
My goal is to keep that time variable as it is, but to convert it in a way to generate a variable called "season" which applies a season number for each group of months.
Is there any help? With thanks!
I have this code:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str3 Code int(Nombre_Voyageurs_Mois_Ligne Mois) float Voyageurs_par_Ligne int Distance float Temps_de_Trajet "170" 526 744 8279 160 180 "512" 1212 744 102064 541 475 "178" 27 744 510 556 565 "503" 1003 744 70957 563 570 "129" 9 744 423 165 180 "189" 3307 744 84738 551 525 "133" 54 744 3038 181 210 "101" 2092 744 82755 370 390 "142" 948 744 12672 590 480 "138" 409 744 28700 172 180 "152" 2000 744 54501 171 195 "106" 191 744 2508 291 285 "118" 1623 744 51833 207 210 "107" 2330 744 74227 323 310 "502" 1012 744 86735 590 600 "506" 2530 744 81870 509 510 "113" 3311 744 105130 246 270 "105" 2419 744 78207 270 240 "135" 2248 744 64820 286 300 "122" 2197 744 84414 202 230 "175" 3 744 453 248 210 "117" 34 744 777 520 480 "300" 2232 744 58633 160 165 "146" 18 744 6382 471 490 "510" 2 744 4261 452 450 "136" 50 744 265 323 300 "103" 4 744 20402 404 400 "134" 4 744 238 323 330 "110" 754 744 18088 226 240 "168" 7 744 372 186 300 "115" 2227 744 77793 207 220 "183" 2941 744 82723 465 420 "116" 3 744 2353 286 300 "109" 32 744 569 172 180 "123" 2822 744 90892 212 245 "151" 8 744 9720 181 210 "131" 1845 744 56519 157 165 "125" 1 744 235 177 195 "145" 879 744 39787 200 225 "174" 337 744 8466 227 230 "139" 2843 744 94037 172 180 "141" 2517 744 77068 232 270 "124" 111 744 10299 181 210 "509" 1616 744 71740 446 405 "508" 1848 744 75901 333 360 "518" 2953 744 80214 594 530 "194" 3018 744 81208 605 570 "219" 9 744 425 554 360 "149" 3540 744 95732 485 435 "173" 117 744 25727 160 180 "182" 7 744 540 288 270 "507" 495 744 36231 547 495 "162" 3189 744 82181 397 450 "167" 20 744 420 323 300 "153" 3 744 214 171 195 "192" 468 744 13568 232 270 "169" 61 744 6882 202 240 "102" 3895 744 107070 488 510 "501" 1092 744 82224 487 445 "143" 1443 744 84410 465 420 "321" 1 744 130 160 165 "119" 185 744 1620 172 180 "100" 3146 744 88500 370 280 "104" 2220 744 63134 563 510 "517" 1572 744 88206 606 660 "179" 3183 744 106033 696 660 "176" 89 744 1611 214 240 "504" 1105 744 69920 551 530 "108" 3155 744 91167 246 270 "164" 2012 744 74352 246 250 "209" 4110 744 88627 502 465 "114" 2013 744 80847 232 270 "206" 2018 744 62786 177 195 "182" 6 745 540 288 270 "149" 3443 745 95732 485 435 "168" 1 745 372 186 300 "119" 39 745 1620 172 180 "518" 2880 745 80214 594 530 "162" 2502 745 82181 397 450 "209" 3696 745 88627 502 465 "124" 58 745 10299 181 210 "507" 599 745 36231 547 495 "135" 2382 745 64820 286 300 "113" 3634 745 105130 246 270 "502" 1407 745 86735 590 600 "106" 5 745 2508 291 285 "134" 6 745 238 323 330 "504" 1529 745 69920 551 530 "175" 21 745 453 248 210 "176" 6 745 1611 214 240 "138" 581 745 28700 172 180 "153" 4 745 214 171 195 "189" 3050 745 84738 551 525 "132" 1 745 21312 149 160 "503" 1320 745 70957 563 570 "151" 23 745 9720 181 210 "194" 2414 745 81208 605 570 "108" 2894 745 91167 246 270 "167" 18 745 420 323 300 "164" 2111 745 74352 246 250 end format %tmMonth_CCYY Mois
My goal is to keep that time variable as it is, but to convert it in a way to generate a variable called "season" which applies a season number for each group of months.
Is there any help? With thanks!
Comment