Listing of Observation:
Code:
title "Outliers Based on Interquartile Range";
proc means data=a4lib.bike noprint;
var windspeed;
output out=Tmp
Q1=
Q3=
QRange= / autoname;
run;
data _null_;
file print;
set a4lib.bike(keep=instant windspeed);
if _n_ = 1 then set Tmp;
if windspeed le windspeed_Q1 - 1.5*windspeed_QRange and not missing(windspeed) or
windspeed ge windspeed_Q3 + 1.5*windspeed_QRange then
put "Possible Outlier for instant " instant "Value of Windspeed is " windspeed "count" cnt;
run;
Output:
Outliers Based on Interquartile Range
Possible Outlier for instant 45 Value of Windspeed is 0.417908 count. Possible Outlier for instant 50 Value of Windspeed is 0.507463 count. Possible Outlier for instant 94 Value of Windspeed is 0.385571 count. Possible Outlier for instant 95 Value of Windspeed is 0.388067 count. Possible Outlier for instant 293 Value of Windspeed is 0.422275 count. Possible Outlier for instant 383 Value of Windspeed is 0.415429 count. Possible Outlier for instant 408 Value of Windspeed is 0.409212 count. Possible Outlier for instant 421 Value of Windspeed is 0.421642 count. Possible Outlier for instant 433 Value of Windspeed is 0.441563 count. Possible Outlier for instant 434 Value of Windspeed is 0.4148 count. Possible Outlier for instant 451 Value of Windspeed is 0.386821 count. Possible Outlier for instant 667 Value of Windspeed is 0.398008 count. Possible Outlier for instant 722 Value of Windspeed is 0.407346 count.
Instead of showing the value for cnt variable dot is showing.
Desired Output:
possible outlier for instant45 value of windspeed is 0.417908 count=1913 possible outlier for instant50 value of windspeed is 0.507463 count=1635 possible outlier for instant94 value of windspeed is 0.385571 count=3115 possible outlier for instant95 value of windspeed is 0.388067 count=1795 possible outlier for instant293 value of windspeed is 0.422275 count=4195 possible outlier for instant383 value of windspeed is 0.415429 count=3376 possible outlier for instant408 value of windspeed is 0.409212 count=1529 possible outlier for instant421 value of windspeed is 0.421642 count=2732 possible outlier for instant433 value of windspeed is 0.441563 count=5382 possible outlier for instant434 value of windspeed is 0.4148 count=4569 possible outlier for instant451 value of windspeed is 0.386821 count=5558 possible outlier for instant667 value of windspeed is 0.398008 count=4459 possible outlier for instant722 value of windspeed is 0.407346 count=1749
Add CNT to your keep statement.
Thank you. Its has worked.
Please mark the thread as solved.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.