Announcement

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

  • Time variable in graph bar

    Hi,

    I am creating some charts with graph bar and have a time variable called time (type: float, format: %tq) which is specified in the over option.The variable takes 3 values (2005q4, 2010q4, 2015q4) and I want to show them in the chart.

    The simplified version of the code I run looks as follows:
    Code:
    graph bar (sum) y1, over(time)
    The time values I get on the chart are 183, 203, and 223 which is not what I want. Does anyone know how I can get 2005q4, 2010q4, 2015q4 on the chart?

    Cheers,
    Giovanni





  • #2
    Interesting question. As the categorical axis variable is expected to be ... categorical, there doesn't appear to be an option to control label display format directly.

    But you can easily assign the date formats to a string variable and plot in terms of that. They will be in the right sort order.

    Run this to see the idea, while noting that a little self-contained data example given in this way would have saved me a little time: See FAQ Advice #2.

    Code:
    clear 
    input time y1 
    183    42
    203    44 
    223    46 
    end 
    
    graph bar (sum) y1, over(time) 
    gen label = string(time, "%tq")
    graph bar (sum) y1, over(label)
    If you want a different display format, see

    Code:
    help datetime_display_formats

    Comment


    • #3
      Thanks Nick! I also tried over(time, format(%tq))but it didn't do the trick.
      Last edited by Giovanni Palmioli; 03 Jun 2016, 15:59.

      Comment


      • #4
        Works well with quarter (%tq) data, but not with monthly (%tm) as the sort order puts 2022m10 before 2022m2. Have to specify the format with NN.
        Code:
        gen label = string(time, "%tmCCYY!mNN")
        .
        Last edited by alejoforero; 13 Jan 2023, 09:53. Reason: (Better solution found)

        Comment


        • #5
          My 2016 advice is superseded by https://journals.sagepub.com/doi/pdf...6867X211000032 -- especially switching to twoway bar !

          Comment


          • #6
            Originally posted by [url
            https://journals.sagepub.com/doi/pdf/10.1177/1536867X211000032[/url]
            This is really helpful using the mod function. How would one modify the mod code so that dates are every 30 days.


            Code:
            *** get the date ranges in order
            summ date
            local x1 = `r(min)'
            local x2 = `r(max)' + 5
            
            *label val date
            * Create a gap every 30 units on the x-axis using forvalues loop
            local call ""
            forvalues j = `x1'(30)`x2' {
                   local call `call' `j' " "  // Add the value to the call macro
                   local remainder = mod(`j', 30)
                   if `remainder' == 0 {
                       local call `call' ""  // Add an empty string to create a gap
                   }
               }
            
            display "`call'"
            
            colorpalette ///
                "48 18 59" ///
                "53 170 249"  ///
                "114 254 94" ///
                "250 186 57" ///
                "202 42 4" ///
                , n(5)     nograph
                
            graph bar (sum) new_cases , percentages over(state) ///
            over(date, relabel(`call') label(angle(forty_five) labsize(minuscule))) ///
            asyvars stack ///
              ylabel(,angle(90)) ytitle ("Daily new cases (%)") ///
                bar(1, fcolor("`r(p1)'") lcolor(black) lwidth(vvthin)) ///
              bar(2, fcolor("`r(p2)'") lcolor(black) lwidth(vvthin)) ///
              bar(3, fcolor("`r(p3)'") lcolor(black) lwidth(vvthin)) ///
              bar(4, fcolor("`r(p4)'") lcolor(black) lwidth(vvthin)) ///
              bar(5, fcolor("`r(p5)'") lcolor(black) lwidth(vvthin)) ///
              legend(off)


            Code:
            * Example generated by -dataex-. For more info, type help dataex
            clear
            input float(date state) double new_cases
            21995 1 29
            21995 2  2
            21995 3  4
            21995 4 19
            21995 5 24
            21996 1 15
            21996 2  3
            21996 3  4
            21996 4 14
            21996 5 31
            21997 1 16
            21997 2  1
            21997 3  5
            21997 4 27
            21997 5 45
            21998 1 10
            21998 2  2
            21998 3  2
            21998 4 24
            21998 5 35
            21999 1 19
            21999 2  1
            21999 3 14
            21999 4 17
            21999 5 31
            22000 1 15
            22000 2  5
            22000 3 12
            22000 4  9
            22000 5 31
            22001 1 21
            22001 2  7
            22001 3 16
            22001 4 31
            22001 5 78
            22002 1 28
            22002 2  5
            22002 3 28
            22002 4 36
            22002 5 39
            22003 1 33
            22003 2  7
            22003 3  8
            22003 4 32
            22003 5 40
            22004 1 65
            22004 2  1
            22004 3 33
            22004 4 24
            22004 5 64
            end
            format %tdDD-Mon-yy date

            Comment


            • #7
              I think this is simpler than it may seem. With daily data, showing dates once every 30 days makes most sense if you have about 6 months to 1 year's worth of data. Much less, and finer resolution of axis labels is possible. Much more, and coarser resolution is essential.

              With that amount of data, forget graph bar and hard work setting 29 of every 30 labels to blank. (Your code looks confused, but possibly has it the wrong way round, setting 1 out of 30 labels to blank.)

              Use twoway bar -- or even better line -- for such data.

              This works more or less and may help. A refinement would be to add one more label.

              Code:
              clear
              set obs 365
              gen date = 21994 + _n 
              
              summ date, meanonly 
              local mean = r(mean)
              
              numlist "`r(min)'(30)`r(max)'"
              local call `r(numlist)'
              
              gen foo = 1 + 2 * (date - `mean') + rnormal(0, .1)
              
              line foo date, xla(`call', format(%tddd_Mon))

              Comment


              • #8
                Hi Nick,

                Many thanks for your insights. I am trying to combine the areaplot below with a stacked bar graph for the region.

                Click image for larger version

Name:	stream_deaths_w1.png
Views:	3
Size:	206.0 KB
ID:	1739162

                The bar graph that I have with the above code looks like this -

                Click image for larger version

Name:	bar_cases_w1.png
Views:	2
Size:	125.3 KB
ID:	1739164
                I am stacking daily covid cases across 5 regions over time for the bar graph. Any suggestions on how to make the dates legible?



                Code:
                * Example generated by -dataex-. For more info, type help dataex
                clear
                input float(date state) double(new_cases new_deaths)
                21995 1  29  0
                21995 2   2  0
                21995 3   4  0
                21995 4  19  0
                21995 5  24  0
                21996 1  15  0
                21996 2   3  0
                21996 3   4  0
                21996 4  14  0
                21996 5  31  0
                21997 1  16  0
                21997 2   1  0
                21997 3   5  0
                21997 4  27  0
                21997 5  45  0
                21998 1  10  0
                21998 2   2  0
                21998 3   2  0
                21998 4  24  0
                21998 5  35  0
                21999 1  19  0
                21999 2   1  0
                21999 3  14  0
                21999 4  17  0
                21999 5  31  0
                22000 1  15  0
                22000 2   5  0
                22000 3  12  0
                22000 4   9  0
                22000 5  31  1
                22001 1  21  0
                22001 2   7  0
                22001 3  16  0
                22001 4  31  0
                22001 5  78  1
                22002 1  28  0
                22002 2   5  0
                22002 3  28  0
                22002 4  36  0
                22002 5  39  0
                22003 1  33  5
                22003 2   7  2
                22003 3   8  2
                22003 4  32 13
                22003 5  40  3
                22004 1  65  2
                22004 2   1  1
                22004 3  33  2
                22004 4  24  3
                22004 5  64  5
                22005 1  53  2
                22005 2  22  1
                22005 3  28  1
                22005 4  86  1
                22005 5 118  1
                22006 1  72  0
                22006 2  19  0
                22006 3  45  3
                22006 4  46  5
                22006 5 242  3
                22007 1 173  3
                22007 2  23  0
                22007 3  23  2
                22007 4  89  6
                22007 5 177  0
                22008 1 160  3
                22008 2  24  0
                22008 3  99  0
                22008 4  72  7
                22008 5 205  4
                22009 1 148  1
                22009 2   5  0
                22009 3  92  3
                22009 4 162  7
                22009 5 172  2
                22010 1 142  3
                22010 2  46  0
                22010 3  62  3
                22010 4 132 14
                22010 5 227  2
                22011 1  95  3
                22011 2   2  0
                22011 3  95  2
                22011 4 139  8
                22011 5 152  3
                22012 1 171  4
                22012 2  21  1
                22012 3  61  6
                22012 4 179 14
                22012 5 141  2
                22013 1 197  2
                22013 2   9  2
                22013 3  84  4
                22013 4 128 10
                22013 5 147  2
                22014 1 185  5
                22014 2  39  1
                22014 3 127  9
                22014 4 305 27
                22014 5 157  4
                end
                format %tdDD-Mon-yy date
                Attached Files

                Comment


                • #9
                  #8 doesn't hang together as a question. The data example covers 10 days. The plots refer to a longer period. I can't see the code for either plot. I can't read what is on the x axis for the last plot.

                  My suggestion remains use of

                  Code:
                   
                   format(%tddd_Mon)
                  as you can state just once that your data are for 2020-21 which in any case may well be evident from the context of whatever you're writing.

                  My own take is that sloping axis labels are to be avoided at all costs -- which doesn't mean that I have always been successful in avoiding myself, but it does mean that I have tried to avoid them. By using the format given above your date labels can be horizontal and should not overlap.

                  I have not found stacked designs nearly as effective as showing series separately. In principle a stacked design gives all the detail of all the component series; in practice it is hard for readers to interpret that detail.

                  I don't understand the logic of your first plot, which is closer to data art and doesn't seem straightforward as a statistical graphic. My review at https://www.amazon.co.uk/Questions-D.../dp/1032139447 says more on the tensions between statistics and art.

                  In Covid datasets I have seen there are weekly cycles that are largely artefacts of data reporting conventions and delays. That may be behind some vibratory effects I think I see in your graphs. If so, smoothing with e.g. a binomial filter with weights 1 6 15 20 15 6 1 / 64 may reduce such noise.

                  Comment


                  • #10
                    Hi Nick,
                    Thank you for the helpful thoughts. What I am trying to do is replicate the graph below Steven Bernand. The graph was COVID cases around the globe by region. I want to do something similar but for regions in India and by COVID waves - wave 1(March 2020 to December 2020), wave 2 (January 2021 to October 2021).

                    Click image for larger version

Name:	original-chart.png
Views:	1
Size:	380.6 KB
ID:	1739379


                    I have managed to create 7-day moving average areaplot for the regions. The first part of the graph (below)
                    Click image for larger version

Name:	stream_deaths_w1.png
Views:	3
Size:	206.0 KB
ID:	1739381

                    What I need to do is create the stacked bar chart. I agree with you that daily cases might not be the best way. I did a 7-day moving average and it looks like this. Would you recommend this? or what would you recommend?
                    Click image for larger version

Name:	bar_cases_w1.png
Views:	2
Size:	122.7 KB
ID:	1739383
                    The code that I use for the bar chart is below. You should be able to run it

                    Code:
                    clear
                    cls
                    
                    import delimited "https://data.covid19india.org/csv/latest/states.csv"
                    gen date1=date(date,"YMD")
                    gen date2=date(date,"YMD")
                    format date2 %td
                    format %tdDD/NN/CCYY date2
                    
                    drop date
                    ren date2 date
                    order date date1
                    label variable tested "Tested cummulative"
                    drop if state=="State Unassigned"
                    
                    
                    gen lgd_state_id=.
                    replace lgd_state_id=1 if state=="Jammu and Kashmir"
                    replace lgd_state_id=2 if state=="Himachal Pradesh"
                    replace lgd_state_id=3 if state=="Punjab"
                    replace lgd_state_id=4 if state=="Chandigarh"
                    replace lgd_state_id=5 if state=="Uttarakhand"
                    replace lgd_state_id=6 if state=="Haryana"
                    replace lgd_state_id=7 if state=="Delhi"
                    replace lgd_state_id=8 if state=="Rajasthan"
                    replace lgd_state_id=9 if state=="Uttar Pradesh"
                    replace lgd_state_id=10 if state=="Bihar"
                    replace lgd_state_id=11 if state=="Sikkim"
                    replace lgd_state_id=12 if state=="Arunachal Pradesh"
                    replace lgd_state_id=13 if state=="Nagaland"
                    replace lgd_state_id=14 if state=="Manipur"
                    replace lgd_state_id=15 if state=="Mizoram"
                    replace lgd_state_id=16 if state=="Tripura"
                    replace lgd_state_id=17 if state=="Meghalaya"
                    replace lgd_state_id=18 if state=="Assam"
                    replace lgd_state_id=19 if state=="West Bengal"
                    replace lgd_state_id=20 if state=="Jharkhand"
                    replace lgd_state_id=21 if state=="Odisha"
                    replace lgd_state_id=22 if state=="Chhattisgarh"
                    replace lgd_state_id=23 if state=="Madhya Pradesh"
                    replace lgd_state_id=24 if state=="Gujarat"
                    replace lgd_state_id=25 if state=="Dadra and Nagar Haveli and Daman and Diu"
                    replace lgd_state_id=26 if state=="Dadra and Nagar Haveli and Daman and Diu"
                    replace lgd_state_id=27 if state=="Maharashtra"
                    replace lgd_state_id=28 if state=="Andhra Pradesh"
                    replace lgd_state_id=29 if state=="Karnataka"
                    replace lgd_state_id=30 if state=="Goa"
                    replace lgd_state_id=31 if state=="Lakshadweep"
                    replace lgd_state_id=32 if state=="Kerala"
                    replace lgd_state_id=33 if state=="Tamil Nadu"
                    replace lgd_state_id=34 if state=="Puducherry"
                    replace lgd_state_id=35 if state=="Andaman and Nicobar Islands"
                    replace lgd_state_id=36 if state=="Telangana"
                    replace lgd_state_id=37 if state=="Ladakh"
                    replace lgd_state_id=90 if state=="India"
                    order state lgd_state_id
                    
                    foreach var of varlist confirmed recovered deceased tested {
                    bysort state (date) : gen `var'_delta=`var' - `var'[_n-1]
                    }
                    
                    order state lgd_state_id date date1 confirmed confirmed_delta recovered recovered_delta deceased deceased_delta tested tested_delta other
                    
                    foreach var of varlist recovered_delta deceased_delta tested_delta confirmed_delta {
                    replace `var'=0 if `var'==.
                    }
                    
                    
                    bysort state (date) : gen test_pos_ratio= (confirmed/tested)*100
                    bysort state (date) : gen tpr_delta= (confirmed_delta/tested_delta)*100
                    bysort state (date) : gen active= confirmed- (recovered+deceased+other)
                    bysort state (date) : gen death_ratio= deceased /confirmed
                    
                    
                    bysort state (date) : gen active_delta=active -active[_n-1]
                    ren date1 date_stata
                    
                    ********************************************************************************
                    /*Updating population figure Population project 2020. After March 1st 2021 it can updated*/
                    ********************************************************************************
                    
                    gen pop=.
                    replace pop=13305 if state=="Jammu and Kashmir"
                    replace pop=7347 if state=="Himachal Pradesh"
                    replace pop=30099 if state=="Punjab"
                    replace pop=1193 if state=="Chandigarh"
                    replace pop=11270 if state=="Uttarakhand"
                    replace pop=29077 if state=="Haryana"
                    replace pop=20193 if state=="Delhi"
                    replace pop=78273 if state=="Rajasthan"
                    replace pop=227943 if state=="Uttar Pradesh"
                    replace pop=121302 if state=="Bihar"
                    replace pop=670 if state=="Sikkim"
                    replace pop=1519 if state=="Arunachal Pradesh"
                    replace pop=2171 if state=="Nagaland"
                    replace pop=3134 if state=="Manipur"
                    replace pop=1204 if state=="Mizoram"
                    replace pop=4032 if state=="Tripura"
                    replace pop=3256 if state=="Meghalaya"
                    replace pop=34668 if state=="Assam"
                    replace pop=97516 if state=="West Bengal"
                    replace pop=37937 if state=="Jharkhand"
                    replace pop=43852 if state=="Odisha"
                    replace pop=29109 if state=="Chhattisgarh"
                    replace pop=83374 if state=="Madhya Pradesh"
                    replace pop=68862 if state=="Gujarat"
                    replace pop=(441+343) if state=="Dadra and Nagar Haveli and Daman and Diu"
                    replace pop=(441+343) if state=="Dadra and Nagar Haveli and Daman and Diu"
                    replace pop=123295 if state=="Maharashtra"
                    replace pop=52504 if state=="Andhra Pradesh"
                    replace pop=66322 if state=="Karnataka"
                    replace pop=1549 if state=="Goa"
                    replace pop=68 if state=="Lakshadweep"
                    replace pop=35307 if state=="Kerala"
                    replace pop=76049 if state=="Tamil Nadu"
                    replace pop=1537 if state=="Puducherry"
                    replace pop=399 if state=="Andaman and Nicobar Islands"
                    replace pop=37473 if state=="Telangana"
                    replace pop=295 if state=="Ladakh"
                    replace pop=1347121 if state=="India"
                    
                    rename pop pop_1k
                    gen pop=pop_1k*1000
                    
                    ********************************************************************************
                    
                    foreach var of varlist confirmed recovered deceased tested active confirmed_delta recovered_delta deceased_delta tested_delta active_delta {
                    bysort state (date) : gen `var'_pop=(`var' /pop)*100000
                    }
                    
                    label variable recovered_delta " daily change"
                    label variable confirmed_delta "daily change"
                    label variable deceased_delta  "daily change"
                    label variable tested_delta    "daily change"
                    label variable active_delta    "daily change"
                    
                    label variable pop_1k "Population in (000)"
                    label variable pop    "Population as of 2020"
                    
                    /*Cummulative change per 100k people*/
                    label variable confirmed_pop "Per 100k"
                    label variable recovered_pop "Per 100k"
                    label variable deceased_pop  "Per 100k"
                    label variable tested_pop    "Per 100k"
                    label variable active_pop    "Per 100k"
                    
                    /*daily change per 100k people*/
                    label variable confirmed_delta_pop "Per 100k"
                    label variable recovered_delta_pop "Per 100k"
                    label variable deceased_delta_pop  "Per 100k"
                    label variable tested_delta_pop    "Per 100k"
                    label variable active_delta_pop    "Per 100k"
                    
                    
                    gen deceased_delta_pop_=(deceased_delta/pop)
                    gen deceased_delta_pop_2m=(deceased_delta_pop_)*(-2000000)         
                    ********************************************************************************
                    **#                           STACKED BAR
                    ********************************************************************************
                    drop if lgd_state_id>40
                    
                    rename date_stata date2
                    
                    drop if date < 21995  // 21st March 2020 wave 1
                    *drop if date < 22280 //1st Jan 2021 wave 2
                    
                    /*remove the line (later)*/
                    
                    *Drop lakshadweep*
                    drop  if lgd_state_id==31
                    drop if date > 22280 // 31st Decmber 2020 wave 1
                    
                    /*
                    gen date1=date
                    gen lab=string(date, "%tdDD/NN/CCYY")
                    gen dm2=date
                    labmask dm2, values(lab)
                    drop date 
                    rename dm2 date*/
                    
                    ********************************************************************************
                    **********************          CHANGE BELOW HERE      *************************
                    ********************************************************************************
                    /*Keep the variables needed here*/
                    keep date lgd_state_id state confirmed_delta deceased_delta
                    
                    /*renaming the variable to match with code.*/
                    rename confirmed_delta new_cases 
                    rename deceased_delta new_deaths
                    
                    encode state, gen(state2)
                    rename state state_str
                    rename state2 state
                    ********************************************************************************
                    * Classify states into zones
                    gen zone = ""
                    
                    * Northern Zonal Council
                    replace zone = "Northern" if inlist(state_str, "Chandigarh", "Delhi", "Haryana", "Himachal Pradesh", "Jammu and Kashmir", "Ladakh", "Punjab", "Rajasthan")
                    
                    * North Eastern Council
                    replace zone = "North Eastern" if inlist(state_str, "Assam", "Arunachal Pradesh", "Manipur", "Meghalaya", "Mizoram", "Nagaland", "Tripura", "Sikkim")
                    
                    * Central Zonal Council
                    replace zone = "Central" if inlist(state_str, "Chhattisgarh", "Madhya Pradesh", "Uttarakhand", "Uttar Pradesh")
                    
                    * Eastern Zonal Council
                    replace zone = "Eastern" if inlist(state_str, "Bihar", "Jharkhand", "Odisha", "West Bengal")
                    
                    * Western Zonal Council
                    replace zone = "Western" if inlist(state_str, "Dadra and Nagar Haveli and Daman and Diu", "Goa", "Gujarat", "Maharashtra")
                    
                    * Southern Zonal Council
                    replace zone = "Southern" if inlist(state_str, "Andhra Pradesh", "Karnataka", "Kerala", "Puducherry", "Tamil Nadu", "Telangana", "Lakshadweep", "Andaman and Nicobar Islands")
                    
                    encode zone, gen(region1)
                    
                    gen         region=1 if region1==4
                    replace        region=2 if region1==2 | region1==3
                    replace        region=3 if region1==1 
                    replace        region=4 if region1==6
                    replace        region=5 if region1==5 
                    ******************************************************************************
                    collapse (sum) new_cases new_deaths, by(date region /*state lgd_state_id*/)
                    format date %tdDD-Mon-yy
                    format new_cases %9.0fc
                    *** minor cleaning of negative cases
                    replace new_cases = 0 if new_cases < 0
                    replace new_deaths = 0 if new_deaths < 0
                    
                    /*Now we declare the data to be a panel dataset using the xtset command. We can use the panel structure to generate a 7-day moving average to smooth out the series:*/
                    rename region state
                    
                    xtset state date
                    tssmooth ma new_cases_ma7  = new_cases , w(6 1 0) 
                    tssmooth ma new_deaths_ma7  = new_deaths , w(6 1 0) 
                    
                    
                    ********************************************************************************
                    /*Stack graph*/
                    ********************************************************************************
                    ******** next we stack these up*************
                    
                    gen stack_cases  = .
                    gen stack_deaths = .
                    sort date state
                    levelsof date, local(dates)
                    
                    foreach y of local dates {
                      
                      summ state
                    *** cases
                    replace stack_cases  = new_cases_ma7 if date==`y' &  state==`r(min)' 
                    replace stack_cases  = new_cases_ma7  + stack_cases[_n-1]  if  date==`y' & state!=`r(min)'  
                    *** deaths  
                    replace stack_deaths = new_deaths_ma7 if  date==`y' & state==`r(min)' 
                    replace stack_deaths = new_deaths_ma7 + stack_deaths[_n-1]  if  date==`y' & state!=`r(min)' 
                    }
                    
                    keep state date new_cases stack_cases new_deaths stack_deaths // rename just to keep life easy  
                    ren stack_cases   cases
                    ren stack_deaths  deaths
                    
                    ******************************************************************************
                    *** get the date ranges in order
                    summ date
                    local x1 = `r(min)'
                    local x2 = `r(max)' + 5
                    
                    *label val date
                    * Create a gap every 30 units on the x-axis using forvalues loop
                    local call ""
                    forvalues j = `x1'(30)`x2' {
                           local call `call' `j' " "  // Add the value to the call macro
                           local remainder = mod(`j', 30)
                           if `remainder' == 0 {
                               local call `call' ""  // Add an empty string to create a gap
                           }
                       }
                    
                    display "`call'"
                    foreach x in cases deaths{
                    colorpalette ///
                        "48 18 59" ///
                        "53 170 249"  ///
                        "114 254 94" ///
                        "250 186 57" ///
                        "202 42 4" ///
                        , n(5)     nograph
                        
                    
                        graph bar (sum) `x' , percentages over(state) ///
                        over(date, relabel(`call') label(angle(forty_five) labsize(minuscule))) ///
                        asyvars stack ///
                          ylabel(,angle(0)) ytitle("") /*ytitle ("Daily new `x' (%)")*/ ///
                            bar(1, fcolor("`r(p1)'") lcolor(black) lwidth(vvthin)) ///
                          bar(2, fcolor("`r(p2)'") lcolor(black) lwidth(vvthin)) ///
                          bar(3, fcolor("`r(p3)'") lcolor(black) lwidth(vvthin)) ///
                          bar(4, fcolor("`r(p4)'") lcolor(black) lwidth(vvthin)) ///
                          bar(5, fcolor("`r(p5)'") lcolor(black) lwidth(vvthin)) ///
                          legend(off) ///
                        fysize(20)  fxsize(82)
                          
                      graph save "Graph" ./graph/bar_`x'_w1.gph, replace 
                      graph export ./graph/bar_`x'_w1.png, replace wid(2000)
                    
                    }


                    Attached Files

                    Comment


                    • #11
                      You put a lot of work into a reply, so this reaction is likely to seem churlish.

                      The clearer stacked displays in #11 don't change my mind that these are not nearly as effective as simpler designs would be.

                      You've provided a link to the data, but looking at this in more detail would take much more time than I can give right now

                      Clearly the question remains open to anyone.

                      Comment


                      • #12
                        Thanks Nick for your thoughts!

                        Andrew Musau do you have any suggestions as you how to get dates every 30 days in a time-series stacked bar graph? My original question in #6

                        Comment


                        • #13
                          Originally posted by Anustup Kundu View Post
                          My original question in #6
                          I don't know if I follow the question. Do you want the following?

                          Code:
                          *DEFINE SOME VALUES
                          local x1 1
                          local x2 300
                          
                          *WANTED?
                          local call `x1'
                          local j `x1'
                          while `j'<= `x2'-30{
                              local j=`j'+30    
                              local call "`call' `j'"
                          }
                          Res.:

                          Code:
                          . di "`call'"
                          1 31 61 91 121 151 181 211 241 271
                          ADDED IN EDIT: Nick's code in #7 does the above more efficiently, so I guess that I do not understand the question.

                          Code:
                          local x1 1
                          local x2 300
                          numlist "`x1'(30)`x2'"
                          local call `r(numlist)'
                          di "`call'"

                          Can you show based on some values what your intended output is? You can change the values for the locals x1 and x2.
                          Last edited by Andrew Musau; 10 Jan 2024, 23:43.

                          Comment

                          Working...
                          X