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

お世話になっております.

 

SAS 9.3を使っておりますが,

折れ線グラフの点の位置にそのY軸の値を表示させたいのですが,

折れ線がY2AXISの方を参照している場合,ANNOTATEではできないのでしょうか.

 

ANNOTATEを作る際に,

y2space="datavalue";y2=対応する変数;

としてみたのですが,上手くいかずご教示いただけると大変助かります.

 

よろしくお願い申し上げます.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
sasone
Quartz | Level 8

以下の参照資料の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;

View solution in original post

4 REPLIES 4
sasone
Quartz | Level 8

以下の参照資料の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;
Taka_FUK_JPN
Fluorite | Level 6

sasone様

 

ご教示ありがとうございます.

出来ました!

 

Y2SPACE (supported only by the ARROW and LINE functions)

を見たことがあり,出来ないのかな・・・と思っていたところ

良い方法を教えていただきましたありがとうございました.

 

今後ともよろしくお願いします.

yu_sas
SAS Employee

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;

 

Taka_FUK_JPN
Fluorite | Level 6

yu_sas様

 

DATALABEL=オプションは知っていたはずなのですが,

Annotateを使うものとばかり思い込んでいて,まったく頭に浮かびませんでした・・・.

 

ご教示いただいてありがとうございます.

 

今後ともよろしくお願い申し上げます.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Discussion stats
  • 4 replies
  • 1353 views
  • 3 likes
  • 3 in conversation