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

Hi,

Trying to see if there is a away to highlight extreme value point (in this case if value >5) to be marked with red circle or change line color to red.

Data have;
length zone $6;
Input zone RepDate case trend;
informat RepDate ANYDTDTE10.;
FORMAT Repdate mmddyy10.;
Datalines;
A 01/16/2021 1 4.3
A 01/17/2021 1 3.9
A 01/18/2021 12 3.3
A 01/19/2021 16 4.0
A 01/20/2021 2 4.4
A 01/21/2021 5 3.9
A 01/22/2021 6 6.1
;
run;

proc sgplot data=have noautolegend;
vline RepDate / response=trend lineattrs=(color=grey thickness=3 PATTERN=SHORTDASH);

run;

 

bijayadhikar_0-1615985055971.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
bijayadhikar
Quartz | Level 8

@Rick_SAS 

 

I change vline to needle, and used X/Y series as per your suggestion. It did work perfectly as I wanted.

Much appreciated!

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

One way is to use a DATA step to find the outliers (using whatever criterion you want) and then overlay those points as red markers. To do that, you should use the SERIES statement instead of the VLINE statement to draw the line. I think the following is self-explanatory, but write back if the steps are not clear:

Data have;
length zone $6;
Input zone RepDate case trend;
informat RepDate ANYDTDTE10.;
FORMAT Repdate mmddyy10.;
Datalines;
A 01/16/2021 1 4.3
A 01/17/2021 1 3.9
A 01/18/2021 12 3.3
A 01/19/2021 16 4.0
A 01/20/2021 2 4.4
A 01/21/2021 5 3.9
A 01/22/2021 6 6.1
;
run;

data Outliers;
set Have(rename=(trend=Outlier));
if Outlier>5;
run;

data All;
set Have Outliers;
run;

proc sgplot data=All noautolegend;
series x=RepDate y=trend / markers lineattrs=(color=grey thickness=3 PATTERN=SHORTDASH);
scatter x=RepDate y=Outlier / markerattrs=(symbol=CircleFilled size=10 color=red);
refline 5 / axis=y label="Cutoff";
run;
bijayadhikar
Quartz | Level 8

@Rick_SAS 

 

I change vline to needle, and used X/Y series as per your suggestion. It did work perfectly as I wanted.

Much appreciated!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 517 views
  • 0 likes
  • 2 in conversation