DATA Step, Macro, Functions and more

Connect Time Points on Plot

Reply
Occasional Contributor
Posts: 16

Connect Time Points on Plot

[ Edited ]

Good afternoon,

 

I have a plot with start times and end times, e.g. 23:00 start time in red and 04:00 end time in blue, so the end time actually occurs before the start time on the plot. I would like to connect these points, which I have done, but I would like them to connect by wrapping around.

 

E.G.

00:00:00---------------------END                            START--------------------------23:59:59                               SHIFT1

00:00:00                                                    START--------------------------------------END                                SHIFT 2

 

I am currently using sgplot and SAS 9.4. Any suggestions?

 

Thank you.

 

Super User
Posts: 17,831

Re: Connect Time Points on Plot

Add a date component, so it's a date time variable and then graph it using a SERIES statement.

 

Wait...what do you mean by wrapping around?

Occasional Contributor
Posts: 16

Re: Connect Time Points on Plot

Hi Reeza,

 

I have the dates; however, I would like the start times to line up. So, if I have a start time of 13:00 on day 1 and a start time of 14:00 on day 2 then day 2's start time is below day 1 and slightly to the right. I currently the plots organized this way; however, I would like to connect the points. 

 

So, if I have a start time of 14:00 and an end time of 20:00 then it is no problem. The points are connected in the correct fashion. However, if I have a start time of 14:00 and an end time of 02:00 then I would want the line to go off towards the ride and continue on the same line.

 

The plots are organized from 00:00:00 to 23:59:59 on the x-axis and by day # on the y-axis.

Super User
Posts: 17,831

Re: Connect Time Points on Plot

I think you'll have to add some fake data somehow.

 

So if it crosses the 'boundary' then you split the point to represent the two portions:

 

22:00h to 02:00h becomes:

 

0:00 to 02:00h

22:00 to 0:00h

 

If you post better fake data and a picture of what you want your graph to look like you might get some code Smiley Happy

Ask a Question
Discussion stats
  • 3 replies
  • 169 views
  • 0 likes
  • 2 in conversation