BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
annaabimbola
Calcite | Level 5

Hi All,

I'm want to create an XSchart.

The chart was split into 4 instead of 1. Please how do I make this come out as just 1 chart?

The data points for the subgroup variable are 09/01/2020, 10/01/2020,...01/01/2021

Please see the code.

title "Length of Stay";
symbol v=dot;

proc shewhart data=work.nowsbaseline_sorted;
	xschart neonatald*measureperiodid/haxis= '01SEP2020'd to '01MAR2021'd by 31;
run;

Any help is greatly appreciated.

Thanks in advance!

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Since I am not going to type in your screen captures of data, I made up my own data to illustrate.

 

data have;
    input measureperiodid :date9. neonatald;
    format measureperiodid date9.;
    cards;
01OCT2020 40
01NOV2020 3
01DEC2020 19
01FEB2021 40
;

proc sql;
    create table minmax as 
    select min(measureperiodid) as mindate,max(measureperiodid) as maxdate
    from have;
run;

/* Create index values */
data index;
	set minmax;
	index=0;
	date=mindate;
	do until (date>=maxdate);
	    date=intnx('month',mindate,index,'b');
	    index=index+1;
	    year=year(date);
	    month=month(date);
	    output;
    end;
    format date date9.;
    keep index date year month;
run;

data final;
    merge have index(rename=(date=measureperiodid));
    by measureperiodid;
    if missing(neonatald) then neonatald=0;
run;

proc shewhart data=final;
	irchart neonatald*index(year month)/blockpos=3 haxis=1 to 6;
	label year='Year' month='Month';
run;
--
Paige Miller

View solution in original post

10 REPLIES 10
PaigeMiller
Diamond | Level 26

As I suggested in your other thread, make the horizontal axis to be the numbers 1, 2, ... and then use a block variable to identify the months.


Also note that using by 31 in your code, you will not really be displaying months, but time periods of 31 days.

--
Paige Miller
annaabimbola
Calcite | Level 5
Thanks PaigeMiller, this worked.

I'm writing the codes for an external organization and they need something that will be more automated. They have to create these control charts every month because this is an ongoing project and I won't be the one doing that, so I was wondering if there was a way to do this without having to assign index integers to each month every time they do this.

I really appreciate the help.
PaigeMiller
Diamond | Level 26

Assigning index numbers can be automated.

--
Paige Miller
annaabimbola
Calcite | Level 5
What code can I use to do that?
PaigeMiller
Diamond | Level 26

Show me a portion of your data. Explain what changes from month to month that it would need automation.

--
Paige Miller
annaabimbola
Calcite | Level 5

@PaigeMiller  This is an initiative implemented in hospitals. Each hospital reports the number of days a patient stays in the hospital every month. The goal is to create these control charts every month to see how effective the initiative is, so the neonatald variable changes every month.

PaigeMiller
Diamond | Level 26

Since I am not going to type in your screen captures of data, I made up my own data to illustrate.

 

data have;
    input measureperiodid :date9. neonatald;
    format measureperiodid date9.;
    cards;
01OCT2020 40
01NOV2020 3
01DEC2020 19
01FEB2021 40
;

proc sql;
    create table minmax as 
    select min(measureperiodid) as mindate,max(measureperiodid) as maxdate
    from have;
run;

/* Create index values */
data index;
	set minmax;
	index=0;
	date=mindate;
	do until (date>=maxdate);
	    date=intnx('month',mindate,index,'b');
	    index=index+1;
	    year=year(date);
	    month=month(date);
	    output;
    end;
    format date date9.;
    keep index date year month;
run;

data final;
    merge have index(rename=(date=measureperiodid));
    by measureperiodid;
    if missing(neonatald) then neonatald=0;
run;

proc shewhart data=final;
	irchart neonatald*index(year month)/blockpos=3 haxis=1 to 6;
	label year='Year' month='Month';
run;
--
Paige Miller
annaabimbola
Calcite | Level 5
It worked!!!!

Thank you so much for the help and patience.
PaigeMiller
Diamond | Level 26

@annaabimbola 

Let me alert you to change a small part of the above code, removing HAXIS=1 TO 6, as most likely you will have more than 6 months in your real data.

--
Paige Miller
ballardw
Super User

Don't know if this will fix the specific issue by I think you may have "nicer" axis appearance if you use

xschart neonatald*measureperiodid/haxis= '01SEP2020'd to '01MAR2021'd by month;

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 1079 views
  • 1 like
  • 3 in conversation