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

proc boxplotではないSGPlotの箱ひげ図(vbox or hbox)におきまして、
FAROUTLIERのmarkersymbolを通常OUTLIERのmarkersymbolとは変更したいと考えております。

 

FAROUTLIERとは、farLowerFence=q1-((q3-q1)*3)未満か、farUpperFence=q3+((q3-q1)*3)を超えた点です。
OUTLIERを白抜きの○で、FAROUTLIERを塗りつぶしの●にしたいと思っておるのですが、
どこにも答えが出ておりません。
farLowerFenceまたはfarUpperFenceに線を引くというのでもよいと考えています。

 

proc templateやsgannotateを用いた方法でも構いませんので、判りましたら
ご教示のほどよろしくお願いいたします。

イメージしているプログラムは以下です。

proc sgplot data=sashelp.cars ;
  vbox MPG_Highway/group=DriveTrain category=Origin 
    outlierattrs=(symbol=circle) meanattrs=(symbol=circle);
run;
1 ACCEPTED SOLUTION

Accepted Solutions
sasone
Quartz | Level 8

yu_sasさま

 

素晴らしいです。

boxplotparmステートメントの使用で見事に

outlierはcircleに、far outlierはcirclefilledに分かれてくれました。

ありがとうございました。

View solution in original post

2 REPLIES 2
yu_sas
SAS Employee

こんにちは。

 

Far outlierのみのシンボル変更に対応したオプションは残念ながらないと思われます。もし区別したいだけならLABELFARと

DATALABELオプションをVBOXステートメントに追加し、Far outlierにだけラベルを追加するのが一案かなと思います。

 

vbox MPG_Highway/group=DriveTrain category=Origin labelfar datalabel;

シンボルを変更する場合は、Graph Template LanguageのBOXPLOTPARMとSCATTERPLOTステートメントを

組み合わせるればできるかなと思います。ODS OUTPUTステートメントで整形されたデータセットが作成

できるので、これをもとにできそうです。以下に簡単なサンプルを記載するので、ご参考になればと思います!

 

/* データセット作成 */
ods output sgplot=box;
proc sgplot data=sashelp.cars;
  vbox MPG_Highway/group=DriveTrain category=Origin
    outlierattrs=(symbol=circle) meanattrs=(symbol=circle);
run;

/* 変数名の整理とFar outlier用の変数作成 */
data box2;
set box(where=(st^="")
  rename=(box_mpg_highway_x_origin_gro___x=x
          box_mpg_highway_x_origin_gro___y=y
          box_mpg_highway_x_origin_gro__st=st
          box_mpg_highway_x_origin_gro__gp=gp));
  if st='FAROUTLIER' then do;
    faroutlier=y;
    y=.;
  end;
run;

proc template;
  define statgraph boxplotparm1;
    begingraph;
      layout overlay;
        boxplotparm y=y x=x stat=st / group=gp groupdisplay=cluster
         name="VBOX";
       scatterplot x=x y=faroutlier / group=gp groupdisplay=cluster
         clusterwidth=0.7 markerattrs=(symbol=circlefilled);
       discretelegend "VBOX"/ title="DriveTrain";
      endlayout;
    endgraph;
  end;
run;
proc sgrender data=box2 template=boxplotparm1; run;

 

sasone
Quartz | Level 8

yu_sasさま

 

素晴らしいです。

boxplotparmステートメントの使用で見事に

outlierはcircleに、far outlierはcirclefilledに分かれてくれました。

ありがとうございました。

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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