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

I am trying to plot an end of work, that extends beyond a given time boundary. The typical day is 07:00 - 07:00 (wraps over midnight) So I would like to display the scatter 07:00-24:00, a break and then 00:00-06:59; The Date is on the Y axis and the end

screenshot_69.png

Time is on the X axis. Ranges works, but reorders the ranges, so it displays 0:00-24:00, rather than 07:00-24:00 a break and then 00:00-6:59.

How can I force the order of the ranges?

Thank you.

 

proc sgplot data=xxxx;
STYLEATTRS datacontrastcolors =(pink red) datasymbols=(circlefilled);
SCATTER X=bTimeOut Y=bDateIn /group=bCaseType
;
yaxis display=(nolabel) REVERSE values=('Jan2019' 'Feb2019' 'Mar2019' 'Apr2019' 'May2019' 'Jun2019'
'Jul2019' 'Aug2019' 'Sep2019' 'Oct2019' 'Nov2019' 'Dec2019');
xaxis label='Last Case Ending (hr)' ranges=('07:00't - '24:00't '00:00't - '06:59't);

run;

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

Try using your normalized data time values, but get rid of the VALUES option and add the NOTIMESPLIT option, and the VALUESFORMAT option with a time format. Let me know if that works for you.

View solution in original post

11 REPLIES 11
Jagadishkatam
Amethyst | Level 16

Could you please try the below range

 

ranges=('00:00't - '06:59't '07:00't - '24:00't)
Thanks,
Jag
SSTEAD
Obsidian | Level 7

No change.

SSTEAD
Obsidian | Level 7

I have changed the bTimeOut variable to a datetime. It correctly places the value, but now I hav 01Jan60 and 02Jan60 suffixes after the time value on the x axis. I have tried "format bTimeOut timeampm.;" but then it reverts to a time variable and increments above 24:00 28:00, 32:00 etc. Any more ideas?

Thank you.

Jagadishkatam
Amethyst | Level 16
Could you please convert the bTimeOut to timepart i.e., derive a new variable from bTimeOut like below and use the new variables for x axis

bTimeOutnew=timepart(bTimeOut);
Thanks,
Jag
SSTEAD
Obsidian | Level 7

Jagadishkatam, Thank you for your replies. 

Here is where I am today. The closest I can get is with the following:

proc sgplot data=lastchance NOAUTOLEGEND; 
STYLEATTRS datacontrastcolors =(pink red) datasymbols=(circlefilled);
SCATTER X=NewTimeDateData Y=Call_Date /group=bCaseType ;
yaxis display=(nolabel)REVERSE
values=('Jan2019' 'Feb2019' 'Mar2019' 'Apr2019' 'May2019' 'Jun2019'
'Jul2019' 'Aug2019' 'Sep2019' 'Oct2019' 'Nov2019' 'Dec2019');
xaxis label='Last Case Ending (hr)'  
/* ranges=('07:00't - '24:00't '24:00't-'48:00't) */
;
Title "Ending Time of Last Case of Day" ;
run;
 
screenshot_71.png

It does plot it correctly, but I since I "normalized" the datetime value to cover each day with a possible day+1 overlap, I get the dates printed.

 

If I add the following format to NewTimeDateData :

format NewTimeDateData timeampm8. ;

I get the following message:

NOTE: The column format TIMEAMPM8 is replaced by an auto-generated format on the axis.

and the output displays this:

 

screenshot_74.png

 

 

If I create bTimeOut to timepart:

 It combines the day0 values and day1 values. Not what I wanted

screenshot_73.png

Jagadishkatam
Amethyst | Level 16
Is it possible to post the dataset screenshot, I wanted to check instead of the format, we need to derive the separate time variable and use that as x axis. I am not sure if you are doing it.
Thanks,
Jag
SSTEAD
Obsidian | Level 7

Here is the Code, Dataset Screenshot and resulting Plot. As you can see, it is incorrect. I wanted the times 0:00-6:00 to follow 24:00. They neve will with this method.

proc sgplot DATA=lastchance ; 

format bTimeOutnew time. ; 

SCATTER X=bTimeOutnew Y=Call_Date /group=bCaseType attrid=CaseType markerattrs=(symbol=circlefilled size =11);

yaxisdisplay=(nolabel)REVERSE

values=('Jan2019' 'Feb2019' 'Mar2019' 'Apr2019' 'May2019' 'Jun2019'

'Jul2019''Aug2019''Sep2019''Oct2019''Nov2019''Dec2019');

xaxis label='Last Case Ending (hr)' ;

Title "Call Cases Using TIME FORMATTED Value" ;

run;

SGPlot2.png

screenshot_75.png

DanH_sas
SAS Super FREQ

Try the following:

 

proc sgplot data=lastchance NOAUTOLEGEND; 
STYLEATTRS datacontrastcolors =(pink red) datasymbols=(circlefilled);
SCATTER X=NewTimeDateData Y=Call_Date /group=bCaseType ;
yaxis display=(nolabel)REVERSE
values=('Jan2019' 'Feb2019' 'Mar2019' 'Apr2019' 'May2019' 'Jun2019'
'Jul2019' 'Aug2019' 'Sep2019' 'Oct2019' 'Nov2019' 'Dec2019');
xaxis label='Last Case Ending (hr)' notimesplit value=time.;
Title "Ending Time of Last Case of Day" ;
run;
DanH_sas
SAS Super FREQ

Try using your normalized data time values, but get rid of the VALUES option and add the NOTIMESPLIT option, and the VALUESFORMAT option with a time format. Let me know if that works for you.

SSTEAD
Obsidian | Level 7

Hi Dan,

Thank you very much!!! This worked! Here is the code I used and the resulting output:

proc sgplot DATA=lastchance ; 

format NewTimeDateData OBStartTDdata timeampm8. ; 

SCATTER X=NewTimeDateData Y=Call_Date /group=bCaseType attrid=CaseType markerattrs=(symbol=circlefilled size =11);

yaxisdisplay=(nolabel)REVERSE

values=('Jan2019' 'Feb2019' 'Mar2019' 'Apr2019' 'May2019' 'Jun2019'

'Jul2019''Aug2019''Sep2019''Oct2019''Nov2019''Dec2019');

xaxis label='Last Case Ending (hr)' VALUESFORMAT=TIMEAMPM8.;

Title "CALL CASES Using DateTime Value, Normalized to same day" ;

run;

 

SGPlot4.png

SSTEAD
Obsidian | Level 7
That works fine, too. It is probably cleaner the way you just suggested, than declaring the format in a format statement as I did. I get tme same output, which is wanted I was looking for. Thank you.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 11 replies
  • 1548 views
  • 0 likes
  • 3 in conversation