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

Hello,

I am trying to create timeseries graph using proc sgplot but in my case there are multiple records available for single date.this causes following graph to be formed.Here i have two rows for 21 jan .2016-08-03 13_58_56-Project - SAS Enterprise Guide.png

instead i would like to make graph like this:

2016-08-03 13_57_58-Microsoft Excel - SAS Export Jan Mar 2016 and Calculations.png

Is there any way to get 2nd graph?

 

I am using this code:

 

proc sgplot data=work.limits;
series x=time_stamp y=test_value/markers ;
refline &bin_lsl/axis=Y label= 'LSL&bin_lsl.' lineattrs=(color ='green' thickness=2 pattern =dashdashdot);
refline &bin_usl/axis=Y label= 'USL&bin_usl.' lineattrs=(color ='green' thickness=2 pattern =dashdashdot);
xaxis discreteorder=data fitpolicy=rotate display=all;
yaxis grid max=&bin_usl min = &bin_lsl ;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

You need to sort the data by the X variable.  There is not a unique way to plot data that has duplicate X values, but in your example you are plotting the high value before the low values, so run the following before you call PROC SGPLOT:

 

proc sort data=work.limits;
   by time_stamp test_value;
run;

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Remove duplicate records before doing the graph?

Rick_SAS
SAS Super FREQ

You need to sort the data by the X variable.  There is not a unique way to plot data that has duplicate X values, but in your example you are plotting the high value before the low values, so run the following before you call PROC SGPLOT:

 

proc sort data=work.limits;
   by time_stamp test_value;
run;

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!

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