BookmarkSubscribeRSS Feed
Bhando
Fluorite | Level 6

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. 

Bhando_0-1678417772795.png

 

 

4 REPLIES 4
Bhando
Fluorite | Level 6
Thanks so much for this. Will try this this weekend. I'm not sure if this applies to me or not given they're using a histogram. But I trust I'll find some useful info here. THanks again!
Ben
DanH_sas
SAS Super FREQ

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!

Dan 

Bhando
Fluorite | Level 6

Wow, Dan, I believe this fixed it!  Thanks so much for this and for sticking with this issue.  I was pretty much ready to give up.  

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 781 views
  • 3 likes
  • 3 in conversation