Announcement

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

  • #16
    I see some values in September, so are you sure that your calender runs from 1Oct - 31Mar? Otherwise, you will still have gaps with some dates in September as there are no observations between Apr-Aug. I will drop these in my illustration below. Below, I use labmask from the Stata Journal.

    Code:
    net install gr0034, from(http://www.stata-journal.com/software/sj8-2)
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(date year month) double kilos
    22189 0 10 217441
    22190 0 10 214775
    22191 0 10 156388
    22192 0 10 141009
    22193 0 10 215526
    22194 0 10 129711
    22195 0 10 169852
    22196 0 10 204643
    22197 0 10 281729
    22198 0 10 412143
    22199 0 10 324678
    22200 0 10 396663
    22201 0 10 460965
    22202 0 10 398581
    22203 0 10 597762
    22204 0 10 556337
    22205 0 10 479245
    22206 0 10 624982
    22207 0 10 670106
    22208 0 10 555994
    22209 0 10 411386
    22210 0 10 440721
    22211 0 10 541893
    22212 0 10 450873
    22213 0 10 400985
    22214 0 10 500747
    22215 0 10 406071
    22216 0 10 731186
    22217 0 10 461157
    22218 0 10 330291
    22219 0 10 219186
    22220 0 11 343361
    22221 0 11 374581
    22222 0 11 463049
    22223 0 11 370848
    22224 0 11 562520
    22225 0 11 530294
    22226 0 11 449209
    22227 0 11 528547
    22228 0 11 533763
    22229 0 11 477947
    22230 0 11 418616
    22231 0 11 369379
    22232 0 11 487571
    22233 0 11 501288
    22234 0 11 429535
    22235 0 11 374690
    22236 0 11 419362
    22237 0 11 455256
    22238 0 11 457892
    22239 0 11 464516
    22240 0 11 431156
    22241 0 11 590224
    22242 0 11 502984
    22243 0 11 703208
    22244 0 11 695350
    22245 0 11 818355
    22246 0 11 822102
    22247 0 11 752457
    22248 0 11 544013
    22249 0 11 825585
    22250 0 12 444274
    22251 0 12 613058
    22252 0 12 513498
    22253 0 12 419795
    22254 0 12 432261
    22255 0 12 211717
    22256 0 12 432832
    22257 0 12 238591
    22258 0 12 345336
    22259 0 12 359076
    22260 0 12 275059
    22261 0 12 258255
    22262 0 12 161090
    22263 0 12 232518
    22264 0 12 284216
    22265 0 12 130504
    22266 0 12 189958
    22267 0 12 195392
    22268 0 12 173444
    22269 0 12 166438
    22270 0 12 212410
    22271 0 12 298384
    22272 0 12 234968
    22273 0 12 224480
    22274 0 12 125155
    22275 0 12 346394
    22276 0 12 352458
    22277 0 12 262452
    22278 0 12 400913
    22279 0 12 395405
    22280 0 12 374545
    22281 0  1  71661
    22282 0  1 385205
    22283 0  1 643502
    22284 0  1 643509
    22285 0  1 676360
    22286 0  1 483264
    22287 0  1 433171
    22288 0  1 451833
    22289 0  1 518764
    22290 0  1 563800
    22291 0  1 541312
    22292 0  1 591733
    22293 0  1 472663
    22294 0  1 277247
    22295 0  1 417866
    22296 0  1 605605
    22297 0  1 491667
    22298 0  1 455746
    22299 0  1 519541
    22300 0  1 537373
    22301 0  1 309939
    22302 0  1 280627
    22303 0  1 262320
    22304 0  1 317909
    22305 0  1 299978
    22306 0  1 382633
    22307 0  1 572021
    22308 0  1 308382
    22309 0  1 268690
    22310 0  1 395303
    22311 0  1 206577
    22312 0  2 151037
    22313 0  2 255222
    22314 0  2  80864
    22315 0  2  21935
    22316 0  2  17483
    22317 0  2   7812
    22318 0  2  27121
    22319 0  2   8382
    22320 0  2  17019
    22321 0  2   6675
    22322 0  2   5969
    22323 0  2   8100
    22324 0  2   7308
    22326 0  2  11820
    22327 0  2  18388
    22328 0  2  29949
    22329 0  2  28561
    22330 0  2  14797
    22331 0  2  37500
    22367 0  3  38110
    22368 0  3  39812
    22369 0  3 119093
    22550 1  9  30572
    22551 1  9  98512
    22552 1  9 182601
    22553 1  9 138817
    22554 1 10 674764
    22555 1 10 558345
    22556 1 10 634476
    22557 1 10 682916
    22558 1 10 789773
    22559 1 10 744648
    22560 1 10 664479
    22561 1 10 622090
    22562 1 10 547615
    22563 1 10 595351
    22564 1 10 702597
    22565 1 10 584840
    22566 1 10 554814
    22567 1 10 622070
    22568 1 10 634559
    22569 1 10 696918
    22570 1 10 723898
    22571 1 10 777443
    22572 1 10 734257
    22573 1 10 651609
    22574 1 10 512716
    22575 1 10 506459
    22576 1 10 553743
    22577 1 10 315231
    22578 1 10 366495
    22579 1 10 410387
    22580 1 10 286126
    22581 1 10 270082
    22582 1 10 474542
    22583 1 10 236578
    22584 1 10 195127
    22585 1 11 388184
    22586 1 11 469820
    22587 1 11 312197
    22588 1 11 217251
    22589 1 11 251247
    22590 1 11 370173
    22591 1 11 324401
    22592 1 11 345120
    22593 1 11 192244
    22594 1 11 357838
    22595 1 11 296727
    22596 1 11 369587
    22597 1 11 209974
    22598 1 11 232645
    22599 1 11 389248
    22600 1 11 297196
    22601 1 11 381549
    22602 1 11 259946
    22603 1 11 448258
    22604 1 11 374545
    22605 1 11 167131
    22606 1 11 148915
    22607 1 11 125862
    22608 1 11 121988
    22609 1 11 308078
    22610 1 11 296548
    22611 1 11 190741
    22612 1 11 228828
    22613 1 11 157088
    22614 1 11 145906
    22615 1 12 125843
    22616 1 12 142378
    22617 1 12 130781
    22618 1 12  98331
    22619 1 12 156848
    22620 1 12  80604
    22621 1 12 155936
    22622 1 12 144203
    22623 1 12 119197
    22624 1 12 136930
    22625 1 12 118505
    22626 1 12 147002
    22627 1 12 152242
    22628 1 12 184725
    22629 1 12 202855
    22630 1 12 249227
    22631 1 12 282639
    22632 1 12 147041
    22633 1 12 194177
    22634 1 12 225637
    22635 1 12 204281
    22636 1 12 222460
    22637 1 12 275612
    22638 1 12 324776
    22639 1 12 115118
    22640 1 12 298012
    22641 1 12 281119
    22642 1 12 324554
    22643 1 12 376365
    22644 1 12 542017
    22645 1 12 647953
    22646 1  1 182062
    22647 1  1 440316
    22648 1  1 590459
    22649 1  1 420291
    22650 1  1 577376
    22651 1  1 453879
    22652 1  1 395481
    22653 1  1 497996
    22654 1  1 459708
    22655 1  1 434478
    22656 1  1 568668
    22657 1  1 484064
    22658 1  1 366658
    22659 1  1 280233
    22660 1  1 393004
    22661 1  1 374622
    22662 1  1 548439
    22663 1  1 489415
    22664 1  1 499840
    22665 1  1 477615
    22666 1  1 455946
    22667 1  1 333159
    22668 1  1 304074
    22669 1  1 546346
    22670 1  1 336759
    22671 1  1 337529
    22672 1  1 222791
    22673 1  1 296321
    22674 1  1 136709
    22675 1  1 324511
    22676 1  1 182665
    22677 1  2 377622
    22678 1  2 171317
    22679 1  2 158570
    22680 1  2 209780
    22681 1  2 198458
    22682 1  2 109427
    22683 1  2 325986
    22684 1  2 310593
    22685 1  2 221924
    22686 1  2 304629
    22687 1  2 147061
    22688 1  2 165274
    22689 1  2 118849
    22690 1  2 230544
    22691 1  2 239814
    22692 1  2 160647
    22693 1  2 148698
    22694 1  2 230646
    22695 1  2 188020
    22696 1  2 372197
    22697 1  2 155793
    22698 1  2 225878
    22699 1  2 221937
    22700 1  2  97887
    22701 1  2  78709
    22702 1  2 143795
    22703 1  2 149986
    22704 1  2 161023
    end
    format %td date
    label values year year
    label def year 0 "2020-2021", modify
    label def year 1 "2021-2022", modify
    
    gen doy= doy(date)
    gen time= doy if inrange(month(date), 10, 12)
    bys year (date): replace time= cond(doy==1,  time[_n-1]+1, time[_n-1]+ doy - doy[_n-1]) if missing(time)
    drop if missing(time)
    bys year (time): gen time1= time[1]
    replace time = time-time1+1
    gen mask= string(date, "%tdDm")
    labmask time, values(mask)
    xtset year time
    set scheme s1color
    xtline kilos, overlay xlab(1(30)181,val) xtitle("") leg( order(1 "2000-2001" 2 "2001-2002") col(1) pos(1) ring(0))
    Res.:

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	107.9 KB
ID:	1720351

    Comment


    • #17
      Thanks a lot Andrew, it worked perfectly fine this time !

      Many thanks for the help on that!

      Comment


      • #18
        I reopen this topic as I'm trying to do something very similar than before. I want to have a two-way line graph plotting values for variable "kilos" over the period october-march, but this time for different sub-groups. This is the current code I'm using :

        Code:
                
                
                collapse (mean) kilos (max) cooperative, by (date_transaction_num year section_status)
                
                generate month = month(date_transaction_num)
                generate day = day(date_transaction_num)
                generate year2 = year(date_transaction_num)
            
                keep if month==10 | month==11 | month==12 | month==1 | month==2 | month==3
                
                gen doy = doy(date_transaction_num)
                gen time = doy if inrange(month(date_transaction_num), 10, 12)
                bys year2 (date_transaction_num): replace time = cond(doy == 1, time[_n-1] + 1, time[_n-1] + doy - doy[_n-1]) if missing(time)
                drop if missing(time)
                bys year2 (time): gen time1 = time[1]
                replace time = time - time1 + 1
                gen mask = string(date_transaction_num, "%tdDm")
            
                set scheme tab2, perm
            
                graph twoway line kilos time if year == 0 & section_status==0 || ///
                       line kilos time if year  == 0 & section_status==1 || ///
                       line kilos time if year  == 0 & section_status==2 , ///
                       xlab(1 "01 Oct" 32 "01 Nov" 62 "01 Dec" 93 "01 Jan" 123 "01 Feb" 151 "01 Mar" ) ///
                       xtitle("") ytitle("Volume")  ///
                       yscale(range(0, 1500)) ylab(0(500)1500, angle(horizontal)) ///
                       legend(order(1 "Control" 2 "Spillover" 3 "Treated") col(1) pos(1) ring(0)) ///
                       saving(part1, replace)
        I'm not sure about changes that need to be make to have values plotted from October to March in this part of the code :

        Code:
                gen doy = doy(date_transaction_num)
                gen time = doy if inrange(month(date_transaction_num), 10, 12)
                bys year2 (date_transaction_num): replace time = cond(doy == 1, time[_n-1] + 1, time[_n-1] + doy - doy[_n-1]) if missing(time)
                drop if missing(time)
                bys year2 (time): gen time1 = time[1]
                replace time = time - time1 + 1
                gen mask = string(date_transaction_num, "%tdDm")

        Here is data example :

        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input float(year date_transaction_num section_status) double kilos_cert long cooperative float(month day year2 doy time time1) str5 mask
        0 22189 1  297.7955010224949 15 10  1 2020 275  1 275 "01Oct"
        0 22189 2 353.01869158878503 15 10  1 2020 275  1 275 "01Oct"
        0 22190 1  315.0296803652968 15 10  2 2020 276  2 275 "02Oct"
        0 22190 2  312.3481781376518 15 10  2 2020 276  2 275 "02Oct"
        0 22191 1  278.7792642140468 15 10  3 2020 277  3 275 "03Oct"
        0 22191 2  299.2186234817814 15 10  3 2020 277  3 275 "03Oct"
        0 22192 1 255.53284671532847 17 10  4 2020 278  4 275 "04Oct"
        0 22192 2 226.82530120481928 15 10  4 2020 278  4 275 "04Oct"
        0 22193 1  350.3415300546448 17 10  5 2020 279  5 275 "05Oct"
        0 22193 2  316.0567375886525 22 10  5 2020 279  5 275 "05Oct"
        0 22194 1  336.3065326633166 18 10  6 2020 280  6 275 "06Oct"
        0 22194 2              333.9 22 10  6 2020 280  6 275 "06Oct"
        0 22195 1  398.6985815602837 22 10  7 2020 281  7 275 "07Oct"
        0 22195 2  317.3891891891892 22 10  7 2020 281  7 275 "07Oct"
        0 22196 0           421.8125 19 10  8 2020 282  8 275 "08Oct"
        0 22196 1  307.2365038560411 22 10  8 2020 282  8 275 "08Oct"
        0 22196 2 313.07142857142856 15 10  8 2020 282  8 275 "08Oct"
        0 22197 0 1085.7142857142858  3 10  9 2020 283  9 275 "09Oct"
        0 22197 1             414.75 22 10  9 2020 283  9 275 "09Oct"
        0 22197 2 348.72586872586874 20 10  9 2020 283  9 275 "09Oct"
        0 22198 0  769.0515463917526 21 10 10 2020 284 10 275 "10Oct"
        0 22198 1  309.1232876712329 15 10 10 2020 284 10 275 "10Oct"
        0 22198 2  437.7694805194805 22 10 10 2020 284 10 275 "10Oct"
        0 22199 0  439.6273764258555 21 10 11 2020 285 11 275 "11Oct"
        0 22199 1 312.63471502590676 18 10 11 2020 285 11 275 "11Oct"
        0 22199 2  443.5045045045045 22 10 11 2020 285 11 275 "11Oct"
        0 22200 0   522.411214953271 21 10 12 2020 286 12 275 "12Oct"
        0 22200 1  322.8980044345898 18 10 12 2020 286 12 275 "12Oct"
        0 22200 2  398.6291208791209 20 10 12 2020 286 12 275 "12Oct"
        0 22201 0 484.81781376518217 21 10 13 2020 287 13 275 "13Oct"
        0 22201 1 315.50905432595573 18 10 13 2020 287 13 275 "13Oct"
        0 22201 2 381.02208835341366 20 10 13 2020 287 13 275 "13Oct"
        0 22202 0 405.81052631578945 21 10 14 2020 288 14 275 "14Oct"
        0 22202 1  253.0014598540146 22 10 14 2020 288 14 275 "14Oct"
        0 22202 2 423.34520547945203 22 10 14 2020 288 14 275 "14Oct"
        0 22203 0 465.49590163934425 21 10 15 2020 289 15 275 "15Oct"
        0 22203 1 292.96437994722953 18 10 15 2020 289 15 275 "15Oct"
        0 22203 2  402.3343373493976 20 10 15 2020 289 15 275 "15Oct"
        0 22204 0  401.8550724637681 21 10 16 2020 290 16 275 "16Oct"
        0 22204 1  445.2257495590829 18 10 16 2020 290 16 275 "16Oct"
        0 22204 2  404.6120857699805 20 10 16 2020 290 16 275 "16Oct"
        0 22205 0 440.06984667802385 21 10 17 2020 291 17 275 "17Oct"
        0 22205 1          500.78125 18 10 17 2020 291 17 275 "17Oct"
        0 22205 2 371.56129032258065 20 10 17 2020 291 17 275 "17Oct"
        0 22206 0  433.5587529976019 21 10 18 2020 292 18 275 "18Oct"
        0 22206 1  291.7133995037221 22 10 18 2020 292 18 275 "18Oct"
        0 22206 2  392.3996383363472 22 10 18 2020 292 18 275 "18Oct"
        0 22207 0  411.5290322580645 21 10 19 2020 293 19 275 "19Oct"
        0 22207 1 415.83716075156576 22 10 19 2020 293 19 275 "19Oct"
        0 22207 2  394.4795081967213 22 10 19 2020 293 19 275 "19Oct"
        0 22208 0 510.61538461538464 21 10 20 2020 294 20 275 "20Oct"
        0 22208 1  270.0464326160815 22 10 20 2020 294 20 275 "20Oct"
        0 22208 2 341.62027491408935 22 10 20 2020 294 20 275 "20Oct"
        0 22209 0 415.14018691588785 21 10 21 2020 295 21 275 "21Oct"
        0 22209 1  337.6624203821656 22 10 21 2020 295 21 275 "21Oct"
        0 22209 2 289.42419080068146 20 10 21 2020 295 21 275 "21Oct"
        0 22210 0              456.6 21 10 22 2020 296 22 275 "22Oct"
        0 22210 1 322.18535469107553 22 10 22 2020 296 22 275 "22Oct"
        0 22210 2  363.6455223880597 22 10 22 2020 296 22 275 "22Oct"
        0 22211 0  398.6479481641469 21 10 23 2020 297 23 275 "23Oct"
        0 22211 1 276.01480263157896 22 10 23 2020 297 23 275 "23Oct"
        0 22211 2 344.66031195840554 22 10 23 2020 297 23 275 "23Oct"
        0 22212 0 427.74666666666667 21 10 24 2020 298 24 275 "24Oct"
        0 22212 1 265.66037735849056 22 10 24 2020 298 24 275 "24Oct"
        0 22212 2  282.2112676056338 22 10 24 2020 298 24 275 "24Oct"
        0 22213 0  523.4765342960288 21 10 25 2020 299 25 275 "25Oct"
        0 22213 1 277.12152777777777 22 10 25 2020 299 25 275 "25Oct"
        0 22213 2  259.9608355091384 17 10 25 2020 299 25 275 "25Oct"
        0 22214 0  512.4808743169399 21 10 26 2020 300 26 275 "26Oct"
        0 22214 1  328.6489028213166 22 10 26 2020 300 26 275 "26Oct"
        0 22214 2  307.5866261398176 22 10 26 2020 300 26 275 "26Oct"
        0 22215 0  343.5924369747899 21 10 27 2020 301 27 275 "27Oct"
        0 22215 1  296.7197898423818 22 10 27 2020 301 27 275 "27Oct"
        0 22215 2  368.6361556064073 22 10 27 2020 301 27 275 "27Oct"
        0 22216 0  442.0842391304348 21 10 28 2020 302 28 275 "28Oct"
        0 22216 1 234.50181488203268 22 10 28 2020 302 28 275 "28Oct"
        0 22216 2           264.6925 22 10 28 2020 302 28 275 "28Oct"
        0 22217 0  467.4109947643979 21 10 29 2020 303 29 275 "29Oct"
        0 22217 1  285.9777015437393 18 10 29 2020 303 29 275 "29Oct"
        0 22217 2  328.2295081967213 22 10 29 2020 303 29 275 "29Oct"
        0 22218 0  592.3365384615385 21 10 30 2020 304 30 275 "30Oct"
        0 22218 1  353.4674418604651 20 10 30 2020 304 30 275 "30Oct"
        0 22218 2  400.2278481012658 22 10 30 2020 304 30 275 "30Oct"
        0 22219 0  570.2567567567568 21 10 31 2020 305 31 275 "31Oct"
        0 22219 1  375.9054545454545 22 10 31 2020 305 31 275 "31Oct"
        0 22219 2 391.16748768472905 22 10 31 2020 305 31 275 "31Oct"
        0 22220 0 474.37692307692305 19 11  1 2020 306 32 275 "01Nov"
        0 22220 1 294.65408805031444 18 11  1 2020 306 32 275 "01Nov"
        0 22220 2 391.38197424892707 20 11  1 2020 306 32 275 "01Nov"
        0 22221 0  396.2637362637363 21 11  2 2020 307 33 275 "02Nov"
        0 22221 1 364.96882494004797 18 11  2 2020 307 33 275 "02Nov"
        0 22221 2 357.15584415584414 20 11  2 2020 307 33 275 "02Nov"
        0 22222 0 288.11897106109325 21 11  3 2020 308 34 275 "03Nov"
        0 22222 1  343.9373814041746 22 11  3 2020 308 34 275 "03Nov"
        0 22222 2 377.39700374531833 22 11  3 2020 308 34 275 "03Nov"
        0 22223 0  318.9439655172414 21 11  4 2020 309 35 275 "04Nov"
        0 22223 1  401.2074074074074 18 11  4 2020 309 35 275 "04Nov"
        0 22223 2  429.4698795180723 22 11  4 2020 309 35 275 "04Nov"
        0 22224 0  287.5677083333333 21 11  5 2020 310 36 275 "05Nov"
        0 22224 1 325.60382513661204 22 11  5 2020 310 36 275 "05Nov"
        end


        At the end, I want something similar to this graph (the only difference is that here values run from October to December) :
        Graph example.png

        Any idea ?
        Last edited by Marine Jouvin; 20 Feb 2024, 03:27.

        Comment


        • #19
          Do you have data that spans October to March? Show us the result of

          Code:
          contract year date_transaction_num
          dataex date_transaction_num if !year, count(160)

          Comment


          • #20
            Thanks for the answer Andrew, here is the code example :

            Code:
            * Example generated by -dataex-. To install: ssc install dataex
            clear
            input float date_transaction_num
            22189
            22190
            22191
            22192
            22193
            22194
            22195
            22196
            22197
            22198
            22199
            22200
            22201
            22202
            22203
            22204
            22205
            22206
            22207
            22208
            22209
            22210
            22211
            22212
            22213
            22214
            22215
            22216
            22217
            22218
            22219
            22220
            22221
            22222
            22223
            22224
            22225
            22226
            22227
            22228
            22229
            22230
            22231
            22232
            22233
            22234
            22235
            22236
            22237
            22238
            22239
            22240
            22241
            22242
            22243
            22244
            22245
            22246
            22247
            22248
            22249
            22250
            22251
            22252
            22253
            22254
            22255
            22256
            22257
            22258
            22259
            22260
            22261
            22262
            22263
            22264
            22265
            22266
            22267
            22268
            22269
            22270
            22271
            22272
            22273
            22274
            22275
            22276
            22277
            22278
            22279
            22280
            end
            format %td date_transaction_num

            Comment


            • #21
              The data that you show is from 1st October - 31 December. You state that you want October to March, but then what should be shown for the months January to March? Should this just be empty?

              Comment


              • #22
                Sorry, the first data example was wrong! Here is the right one :

                Code:
                * Example generated by -dataex-. To install: ssc install dataex
                clear
                input float date_transaction_num
                22189
                22190
                22191
                22192
                22193
                22194
                22195
                22196
                22197
                22198
                22199
                22200
                22201
                22202
                22203
                22204
                22205
                22206
                22207
                22208
                22209
                22210
                22211
                22212
                22213
                22214
                22215
                22216
                22217
                22218
                22219
                22220
                22221
                22222
                22223
                22224
                22225
                22226
                22227
                22228
                22229
                22230
                22231
                22232
                22233
                22234
                22235
                22236
                22237
                22238
                22239
                22240
                22241
                22242
                22243
                22244
                22245
                22246
                22247
                22248
                22249
                22250
                22251
                22252
                22253
                22254
                22255
                22256
                22257
                22258
                22259
                22260
                22261
                22262
                22263
                22264
                22265
                22266
                22267
                22268
                22269
                22270
                22271
                22272
                22273
                22274
                22275
                22276
                22277
                22278
                22279
                22280
                22281
                22282
                22283
                22284
                22285
                22286
                22287
                22288
                22289
                22290
                22291
                22292
                22293
                22294
                22295
                22296
                22297
                22298
                22299
                22300
                22301
                22302
                22303
                22304
                22305
                22306
                22307
                22308
                22309
                22310
                22311
                22312
                22313
                22314
                22315
                22316
                22317
                22318
                22319
                22320
                22321
                22322
                22323
                22324
                22326
                22327
                22328
                22329
                22330
                22331
                22367
                22368
                22369
                end
                format %td date_transaction_num

                Comment


                • #23
                  Then you just map day of the year to time, starting October 1st= 1. You will have a day adjustment due to leap years, but that should not have an effect for purposes of graphing over a 180 day period. Here, the groups will constitute your panel identifier.

                  Code:
                  gen doy= cond(inrange(month(date_transaction_num), 10, 12) & !mod(year(date_transaction_num), 4), ///  
                      doy(date_transaction_num)-274, cond(inrange(month(date_transaction_num), 10, 12) & mod(year(date_transaction_num), 4), ///
                         doy(date_transaction_num)-273, doy(date_transaction_num) + 92))
                   
                  gen mask= string(date, "%tdDm")
                  labmask doy, values(mask)
                  
                  *CALL YOUR PANEL IDENTIFIER "WHICH"
                  xtset which doy
                  Res.:

                  Code:
                  . lab list
                  doy:
                             1 01Oct
                             2 02Oct
                             3 03Oct
                             4 04Oct
                             5 05Oct
                             6 06Oct
                             7 07Oct
                             8 08Oct
                             9 09Oct
                            10 10Oct
                            11 11Oct
                            12 12Oct
                            13 13Oct
                            14 14Oct
                            15 15Oct
                            16 16Oct
                            17 17Oct
                            18 18Oct
                            19 19Oct
                            20 20Oct
                            21 21Oct
                            22 22Oct
                            23 23Oct
                            24 24Oct
                            25 25Oct
                            26 26Oct
                            27 27Oct
                            28 28Oct
                            29 29Oct
                            30 30Oct
                            31 31Oct
                            32 01Nov
                            33 02Nov
                            34 03Nov
                            35 04Nov
                            36 05Nov
                            37 06Nov
                            38 07Nov
                            39 08Nov
                            40 09Nov
                            41 10Nov
                            42 11Nov
                            43 12Nov
                            44 13Nov
                            45 14Nov
                            46 15Nov
                            47 16Nov
                            48 17Nov
                            49 18Nov
                            50 19Nov
                            51 20Nov
                            52 21Nov
                            53 22Nov
                            54 23Nov
                            55 24Nov
                            56 25Nov
                            57 26Nov
                            58 27Nov
                            59 28Nov
                            60 29Nov
                            61 30Nov
                            62 01Dec
                            63 02Dec
                            64 03Dec
                            65 04Dec
                            66 05Dec
                            67 06Dec
                            68 07Dec
                            69 08Dec
                            70 09Dec
                            71 10Dec
                            72 11Dec
                            73 12Dec
                            74 13Dec
                            75 14Dec
                            76 15Dec
                            77 16Dec
                            78 17Dec
                            79 18Dec
                            80 19Dec
                            81 20Dec
                            82 21Dec
                            83 22Dec
                            84 23Dec
                            85 24Dec
                            86 25Dec
                            87 26Dec
                            88 27Dec
                            89 28Dec
                            90 29Dec
                            91 30Dec
                            92 31Dec
                            93 01Jan
                            94 02Jan
                            95 03Jan
                            96 04Jan
                            97 05Jan
                            98 06Jan
                            99 07Jan
                           100 08Jan
                           101 09Jan
                           102 10Jan
                           103 11Jan
                           104 12Jan
                           105 13Jan
                           106 14Jan
                           107 15Jan
                           108 16Jan
                           109 17Jan
                           110 18Jan
                           111 19Jan
                           112 20Jan
                           113 21Jan
                           114 22Jan
                           115 23Jan
                           116 24Jan
                           117 25Jan
                           118 26Jan
                           119 27Jan
                           120 28Jan
                           121 29Jan
                           122 30Jan
                           123 31Jan
                           124 01Feb
                           125 02Feb
                           126 03Feb
                           127 04Feb
                           128 05Feb
                           129 06Feb
                           130 07Feb
                           131 08Feb
                           132 09Feb
                           133 10Feb
                           134 11Feb
                           135 12Feb
                           136 13Feb
                           138 15Feb
                           139 16Feb
                           140 17Feb
                           141 18Feb
                           142 19Feb
                           143 20Feb
                           179 28Mar
                           180 29Mar
                           181 30Mar
                  Last edited by Andrew Musau; 26 Feb 2024, 08:20.

                  Comment


                  • #24
                    Thinking about this question again, you don't have the same months repeated over multiple years. Your sample period is October 2000- March 2001 and you have multiple variables. Unless I am missing something, this calls for nothing special, different from your original question.

                    Code:
                    webuse sp500, clear
                    keep date open high low
                    replace date= date -90
                    keep if date<=td(30 mar 2001)
                    rename (open high low) var=
                    reshape long var, i(date) j(which) string
                    *I ASSUME THIS IS THE STRUCTURE OF YOUR DATA
                    encode which, gen(Which)
                    xtset Which date
                    xtline var, overlay ///
                    xlab(`=td(1oct2000)' `=td(1nov2000)'  `=td(1dec2000)' `=td(1jan2001)' `=td(1feb2001)' `=td(1mar2001)' `=td(30mar2001)', ///
                    format("%tdDm"))  ytitle(Some Var) xtitle("")
                    Click image for larger version

Name:	Graph.png
Views:	1
Size:	49.1 KB
ID:	1744627

                    Comment


                    • #25
                      Thanks for your answers Andrew !

                      Actually, I have data running from October 1st, 2020, to March 27th, 2023 for three groups. Below is a dataex example, which displays only values for the first year (2020) and first months (October and November) :

                      Code:
                      * Example generated by -dataex-. To install: ssc install dataex
                      clear
                      input float(year date_transaction_num section_status) double kilos_cert long cooperative float(month day year2)
                      0 22189 1  297.7955010224949 15 10  1 2020
                      0 22189 2 353.01869158878503 15 10  1 2020
                      0 22190 1  315.0296803652968 15 10  2 2020
                      0 22190 2  312.3481781376518 15 10  2 2020
                      0 22191 1  278.7792642140468 15 10  3 2020
                      0 22191 2  299.2186234817814 15 10  3 2020
                      0 22192 1 255.53284671532847 17 10  4 2020
                      0 22192 2 226.82530120481928 15 10  4 2020
                      0 22193 1  350.3415300546448 17 10  5 2020
                      0 22193 2  316.0567375886525 22 10  5 2020
                      0 22194 1  336.3065326633166 18 10  6 2020
                      0 22194 2              333.9 22 10  6 2020
                      0 22195 1  398.6985815602837 22 10  7 2020
                      0 22195 2  317.3891891891892 22 10  7 2020
                      0 22196 0           421.8125 19 10  8 2020
                      0 22196 1  307.2365038560411 22 10  8 2020
                      0 22196 2 313.07142857142856 15 10  8 2020
                      0 22197 0 1085.7142857142858  3 10  9 2020
                      0 22197 1             414.75 22 10  9 2020
                      0 22197 2 348.72586872586874 20 10  9 2020
                      0 22198 0  769.0515463917526 21 10 10 2020
                      0 22198 1  309.1232876712329 15 10 10 2020
                      0 22198 2  437.7694805194805 22 10 10 2020
                      0 22199 0  439.6273764258555 21 10 11 2020
                      0 22199 1 312.63471502590676 18 10 11 2020
                      0 22199 2  443.5045045045045 22 10 11 2020
                      0 22200 0   522.411214953271 21 10 12 2020
                      0 22200 1  322.8980044345898 18 10 12 2020
                      0 22200 2  398.6291208791209 20 10 12 2020
                      0 22201 0 484.81781376518217 21 10 13 2020
                      0 22201 1 315.50905432595573 18 10 13 2020
                      0 22201 2 381.02208835341366 20 10 13 2020
                      0 22202 0 405.81052631578945 21 10 14 2020
                      0 22202 1  253.0014598540146 22 10 14 2020
                      0 22202 2 423.34520547945203 22 10 14 2020
                      0 22203 0 465.49590163934425 21 10 15 2020
                      0 22203 1 292.96437994722953 18 10 15 2020
                      0 22203 2  402.3343373493976 20 10 15 2020
                      0 22204 0  401.8550724637681 21 10 16 2020
                      0 22204 1  445.2257495590829 18 10 16 2020
                      0 22204 2  404.6120857699805 20 10 16 2020
                      0 22205 0 440.06984667802385 21 10 17 2020
                      0 22205 1          500.78125 18 10 17 2020
                      0 22205 2 371.56129032258065 20 10 17 2020
                      0 22206 0  433.5587529976019 21 10 18 2020
                      0 22206 1  291.7133995037221 22 10 18 2020
                      0 22206 2  392.3996383363472 22 10 18 2020
                      0 22207 0  411.5290322580645 21 10 19 2020
                      0 22207 1 415.83716075156576 22 10 19 2020
                      0 22207 2  394.4795081967213 22 10 19 2020
                      0 22208 0 510.61538461538464 21 10 20 2020
                      0 22208 1  270.0464326160815 22 10 20 2020
                      0 22208 2 341.62027491408935 22 10 20 2020
                      0 22209 0 415.14018691588785 21 10 21 2020
                      0 22209 1  337.6624203821656 22 10 21 2020
                      0 22209 2 289.42419080068146 20 10 21 2020
                      0 22210 0              456.6 21 10 22 2020
                      0 22210 1 322.18535469107553 22 10 22 2020
                      0 22210 2  363.6455223880597 22 10 22 2020
                      0 22211 0  398.6479481641469 21 10 23 2020
                      0 22211 1 276.01480263157896 22 10 23 2020
                      0 22211 2 344.66031195840554 22 10 23 2020
                      0 22212 0 427.74666666666667 21 10 24 2020
                      0 22212 1 265.66037735849056 22 10 24 2020
                      0 22212 2  282.2112676056338 22 10 24 2020
                      0 22213 0  523.4765342960288 21 10 25 2020
                      0 22213 1 277.12152777777777 22 10 25 2020
                      0 22213 2  259.9608355091384 17 10 25 2020
                      0 22214 0  512.4808743169399 21 10 26 2020
                      0 22214 1  328.6489028213166 22 10 26 2020
                      0 22214 2  307.5866261398176 22 10 26 2020
                      0 22215 0  343.5924369747899 21 10 27 2020
                      0 22215 1  296.7197898423818 22 10 27 2020
                      0 22215 2  368.6361556064073 22 10 27 2020
                      0 22216 0  442.0842391304348 21 10 28 2020
                      0 22216 1 234.50181488203268 22 10 28 2020
                      0 22216 2           264.6925 22 10 28 2020
                      0 22217 0  467.4109947643979 21 10 29 2020
                      0 22217 1  285.9777015437393 18 10 29 2020
                      0 22217 2  328.2295081967213 22 10 29 2020
                      0 22218 0  592.3365384615385 21 10 30 2020
                      0 22218 1  353.4674418604651 20 10 30 2020
                      0 22218 2  400.2278481012658 22 10 30 2020
                      0 22219 0  570.2567567567568 21 10 31 2020
                      0 22219 1  375.9054545454545 22 10 31 2020
                      0 22219 2 391.16748768472905 22 10 31 2020
                      0 22220 0 474.37692307692305 19 11  1 2020
                      0 22220 1 294.65408805031444 18 11  1 2020
                      0 22220 2 391.38197424892707 20 11  1 2020
                      0 22221 0  396.2637362637363 21 11  2 2020
                      0 22221 1 364.96882494004797 18 11  2 2020
                      0 22221 2 357.15584415584414 20 11  2 2020
                      0 22222 0 288.11897106109325 21 11  3 2020
                      0 22222 1  343.9373814041746 22 11  3 2020
                      0 22222 2 377.39700374531833 22 11  3 2020
                      0 22223 0  318.9439655172414 21 11  4 2020
                      0 22223 1  401.2074074074074 18 11  4 2020
                      0 22223 2  429.4698795180723 22 11  4 2020
                      0 22224 0  287.5677083333333 21 11  5 2020
                      0 22224 1 325.60382513661204 22 11  5 2020
                      end
                      format %td date_transaction_num
                      label values year year
                      label def year 0 "2020-2021", modify
                      label values section_status section_status
                      label def section_status 0 "Control", modify
                      label def section_status 1 "Spillover", modify
                      label def section_status 2 "Treated", modify
                      I have a value for the variable "kilos_cert" for each group (section_status) running from October to March for each year (quasi-daily data, even if sometimes there are no values for some day).

                      Comment


                      • #26
                        If you want a graph similar to #16, then each group has 4 series: 2000, 2001, 2002 and 2003. So if you want to overlay all lines in one graph, the graph will not be readable. You could create a graph for each group using the -if- qualifier. Taking it from #23:

                        Code:
                        preserve
                        keep if group==1
                        xtset year doy
                        xtline ..., title(group 1)
                        restore, preserve
                        keep if group==2
                        *AND SO ON

                        Comment

                        Working...
                        X