お世話になっております.
SAS 9.3を使っておりますが,
折れ線グラフの点の位置にそのY軸の値を表示させたいのですが,
折れ線がY2AXISの方を参照している場合,ANNOTATEではできないのでしょうか.
ANNOTATEを作る際に,
y2space="datavalue";y2=対応する変数;
としてみたのですが,上手くいかずご教示いただけると大変助かります.
よろしくお願い申し上げます.
以下の参照資料の3ページ目に『Y2SPACE (supported only by the ARROW and LINE functions)』と
ございますので、残念ながらTEXT functionにはY2SPACEは使えないのではないでしょうか。
「How to improve your figure An overview of annotation techniques in Graph Template Language (PhUSE 2014 Paper CS06)」
https://www.lexjansen.com/phuse/2014/cs/CS06.pdf#search=%27How+to+improve+your+figure+An+overview+of...
ただしyaxis="y2";オプションを使えば、TEXTをY2軸に紐づけられるようです。
data stocks;
set sashelp.stocks (where=(date >= "01jan2004"d
and date <= "01dec2005"d
and stock = "IBM"));
run;
data annotate;
label="$97.5";
function="text"; textsize=12; textcolor="red";
x1space="graphpercent";
y1space="datavalue";
x1=90; y1=97.5; anchor="left";
width=100; yaxis="y2";
run;
proc sgplot data=stocks sganno=annotate;
title "Stock Volume vs. Close";
vbar date / response=volume;
vline date / response=close y2axis;
run;
以下の参照資料の3ページ目に『Y2SPACE (supported only by the ARROW and LINE functions)』と
ございますので、残念ながらTEXT functionにはY2SPACEは使えないのではないでしょうか。
「How to improve your figure An overview of annotation techniques in Graph Template Language (PhUSE 2014 Paper CS06)」
https://www.lexjansen.com/phuse/2014/cs/CS06.pdf#search=%27How+to+improve+your+figure+An+overview+of...
ただしyaxis="y2";オプションを使えば、TEXTをY2軸に紐づけられるようです。
data stocks;
set sashelp.stocks (where=(date >= "01jan2004"d
and date <= "01dec2005"d
and stock = "IBM"));
run;
data annotate;
label="$97.5";
function="text"; textsize=12; textcolor="red";
x1space="graphpercent";
y1space="datavalue";
x1=90; y1=97.5; anchor="left";
width=100; yaxis="y2";
run;
proc sgplot data=stocks sganno=annotate;
title "Stock Volume vs. Close";
vbar date / response=volume;
vline date / response=close y2axis;
run;
sasone様
ご教示ありがとうございます.
出来ました!
Y2SPACE (supported only by the ARROW and LINE functions)
を見たことがあり,出来ないのかな・・・と思っていたところ
良い方法を教えていただきましたありがとうございました.
今後ともよろしくお願いします.
sasone様の回答の通り、Y2から始まる変数は矢印や線といった二つの座標を必要とする機能でのみ利用するものになります。どちらの軸を使うかはYAXIS変数で指定することになります。
また、もしグラフ内にデータ点を描画するだけであればDATALABEL=オプションを利用してもよいかなと思います。
proc sort data=sashelp.class out=class nodupkey;
by age;
run;
proc sgplot data=class;
series x=age y=height / markers datalabel=height;
series x=age y=weight / y2axis markers datalabel=weight;
run;
proc sgplot data=class;
vline age / response=height markers datalabel=height;
vline age / response=weight y2axis markers datalabel=weight;
run;
yu_sas様
DATALABEL=オプションは知っていたはずなのですが,
Annotateを使うものとばかり思い込んでいて,まったく頭に浮かびませんでした・・・.
ご教示いただいてありがとうございます.
今後ともよろしくお願い申し上げます.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.