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

Let's say I have this code:

proc sgplot data=have;
series x=var y=var2;
series x=var y=var3;
series x=var y=var4;
xaxis grid values = (0 to 23 by 1);
run;

is there a way I can display each series in different intervals like:

 

series 1: from 0-10 only

series 2: 0-12 and 18-23 BREAK;

series 3: 12-19

?

 

I don't want to change the axis size

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@matt23 wrote:
So there's no way to do this without playing with the data?

Not very difficult:

data plot;
   set have;
   where 0 le x le 23;
   if not (0 le x le 10) then var2=.;
   if 12 lt x lt 18 then var3=.
   if not (12 le x le 19) var4=.;
run;

proc sgplot data=plot;
series x=var y=var2 / break;
series x=var y=var3 / break;
series x=var y=var4 / break;
xaxis grid values = (0 to 23 by 1);
run;

should do it.

 

 

Try it in Excel. See how much manipulation you do.

Some other approaches might involve adding group variables and assigning attributes to make certain groups "invisible" but that's more work I think.

View solution in original post

3 REPLIES 3
ballardw
Super User

the main piece would be to have y variable values as missing for the X values you don't want the series ploted. Then use the option BREAK on the plot statements. Any x value with a missing y would the "break" the series connection.

 

But the DATA has to support this, not just the plot statements.

matt23
Quartz | Level 8
So there's no way to do this without playing with the data?
ballardw
Super User

@matt23 wrote:
So there's no way to do this without playing with the data?

Not very difficult:

data plot;
   set have;
   where 0 le x le 23;
   if not (0 le x le 10) then var2=.;
   if 12 lt x lt 18 then var3=.
   if not (12 le x le 19) var4=.;
run;

proc sgplot data=plot;
series x=var y=var2 / break;
series x=var y=var3 / break;
series x=var y=var4 / break;
xaxis grid values = (0 to 23 by 1);
run;

should do it.

 

 

Try it in Excel. See how much manipulation you do.

Some other approaches might involve adding group variables and assigning attributes to make certain groups "invisible" but that's more work I think.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 1088 views
  • 0 likes
  • 2 in conversation