What about this? I have generated a new variable AMc which is equal to the variable AM so that -xchart- can be used. It does not change the results. Now, the 0's are not in the calculation of the lower and the upper limits but they are plotted in the graphs where they appear as out of limits.
I think it is impossible to control the number of days in the x-axis; the graph of every week starts from day 1.
Abraham
I think it is impossible to control the number of days in the x-axis; the graph of every week starts from day 1.
Code:
gen AMc = AM levelsof week, local(levels) foreach i of local levels { preserve keep if week == `i' qui sum AM , detail local x = r(mean) display `x' local s = r(sd) display `s' local u =`x'+(3*`s') display `u' local t =`x'-(3*`s') display `t' local z =`x'-(100*`s') replace AM=0 if AM==. replace AMc=0 if AMc==. xchart AM AMc , lower(`t') upper(`u') connect(l ) saving(graph`i', replace) local total`i' = r(N) local violations`i' = r(out_x) local AMscore`i' = (1-(`violations`i''/`total`i''))*100 display `AMscore`i'' restore }
Comment