I am trying to graph monthly prevalence of 2 diseases over a 6 year time period. I'm using proc sgpanel to break up the 4 hospitals data. I'm using the 'band' function to delineate between pre and post an EHR changeover. I created a dummy variable to indicate which EHR was associated with that particular year/month (my x-axis is date). Everything seemed to work...EXCEPT - I have a white band between the banded groups. I have checked the underlying data several times and there is no gap in the data. I have read the documentation on the band function, consulted several books and even asked ChatGPT (which did horrible!).
There's really nothing of value from the log and again, there are no gaps in the data that would indicate there should be a white space here.
Here is the code (a few var names changed):
proc sgpanel data=enc; where fisc_monyr >= '01Nov2015'd; panelby hosp / layout=rowlattice onepanel novarname uniscale=column; series x=fisc_monyr y=var1 / Name="var1" legendlabel='varname' lineattrs=(color=black); series x=fisc_monyr y=var2 / Name="var2" legendlabel='varname2' lineattrs=(color=crimson); band x=fisc_monyr upper=var1 lower=0 /name="band" legendlabel="bandvar" NOMISSINGGROUP group=post_gen transparency=0.7; format post_gen post_genf.; colaxis grid values=('01Nov2015'd, '01Nov2016'd to '01Nov2020'd by year,'01Oct2021'd) offsetmin=0 offsetmax=0 valuesformat=monyy. label="Month-Year" ; rowaxis grid label="Encounters per month"; format fisc_monyr monyy.; /*Add refline for ehr date*/ refline covid_start / name="cov" axis=x label=covid_label labelattrs=(color=black Family=arial size=7) legendlabel="COVID19 Start" lineattrs=(color=black pattern=dot thickness=1) ; keylegend "var1" "var2" "band"; run;
Here is the band I was referring to: The white space between the blue and red fill. Is there anything obvious I'm doing wrong here? Thanks in advance for all your help. This community has been so great in helping to build this graph.
It appears that the gap is created because you start the second band on the next data increment of the series instead of where the first band actually stops. For example, if your X data range went from 1 - 10, and the first band stopped at 5, you are starting the next band at 6 instead of at 5. This leaves a gap between 5 and 6. You probably just need to adjust your data processing to start the second band at the previous "X" step.
Hope this helps!
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.