Help using Base SAS procedures

Advanced question: Proc Gplot and POINTLABEL option in Symbol statement

Reply
Contributor
Posts: 29

Advanced question: Proc Gplot and POINTLABEL option in Symbol statement

I am using the following code (pay attention to symbol3 in particular):

goptions reset=all;
Proc Gplot data=set5;
plot ucl*N=alpha / vaxis=axis1 haxis=axis2 legend=legend1 vref=.03 cvref=ltgray lvref=2 noframe;
symbol1 c=yellow i=join h=.5;
symbol2 c=lime i=join h=.5;

symbol3 v=dot cv=black pointlabel=("#threshold" c=black position=top);

axis1 order=(0 to .5 by .1) label=(a=90 c=black "Upper Confidence Limit (%)")
value=(h=1.5 '0%' '10%' '20%' '30%' '40%' '50%') minor=(number=1) color=black;
axis2 order=(10 to 120 by 10) label=(c=black "Patients Enrolled")
value=(h=1.5) minor=none color=black;
legend1 position=(inside top right) value=(c=black h=1.5 "95% CL (Alert)" "80% CL (Watch)" "Threshold")
label=none down=3 across=1;
Run; Quit;


Threshold is a fourth variable (UCL*N), the values of which I want to use as labels at a few given values of N and UCL, along the lines represented by symbol1 and symbol2. The dots are placed appropriately, but the actual pointlabels are missing. This is the note from the log:

NOTE: At least one pointlabel has overwritten a boundary. This resulted in the affected pointlabel(s) being repositioned.

I do not understand what it means?
Contributor
Posts: 29

Re: Advanced question: Proc Gplot and POINTLABEL option in Symbol statement

Here is how I defined my dataset if you'd like to try it out. Sorry for the lack of indenting but it wouldn't paste properly:


Data set1;
do N=10 to 120;
do i=1 to 2;
if i=1 then alpha=0.05;
if i=2 then alpha=0.2;
Outcome='Death';
Rate=.03;
output;
end;
end;
Run;

Data set2;
set set1;
z=-probit(alpha/2);
lcl=+((2*N*rate+Z*Z-1)-Z*sqrt(Z*Z-(2+1/N)+4*rate*(N*(1-rate)+1)))/2/(N+Z*Z);
ucl=+((2*N*rate+Z*Z+1)+Z*sqrt(Z*Z+(2-1/N)+4*rate*(N*(1-rate)-1)))/2/(N+Z*Z);
count=N*ucl;
if floor(count)=count then threshold=count;
else threshold=floor(count)+1;
Run;

Proc sort data=set2; by outcome alpha n; Run;

Data set3;
set set2;
by outcome alpha threshold;
if ^first.threshold then threshold=.;
run;

Data set5;
set set2(in=a rename=(alpha=alp))
set3(in=b where=(threshold^=.) rename=(alpha=alp));
if a and alp=.05 then alpha=1;
if a and alp=.2 then alpha=2;
if b then alpha=3;
Run;


And another note....my first attempt was to use the SET2 dataset as-is, but I don't want pointlabels at every single point. Only the ones where threshold changes; hence, set3. Thanks!!!
Super Contributor
Posts: 273

Re: Advanced question: Proc Gplot and POINTLABEL option in Symbol statement

I don't have those note with the code you have posted
the only one i got is
WARNING: Can not use MODE=RESERVE and POSITION=(INSIDE). Changed to MODE=PROTECT. and it disappear as soon as i specify mode=share in legend
Your program produce no more note or error!

but your problem is related to what the documentation say about pointlabel
"The variables that you specify must be the plot's X and Y variables. Specifying any other variables will cause unexpected labeling. "

I tried with this code and it seems working avoiding explicitly interpol and allowing repeat 11 times following your max value of threshold

[PRE]
goptions reset=all ;
Proc Gplot data=set5;
plot ucl*N=alpha / vaxis=axis1 haxis=axis2 legend=legend1 vref=.03 cvref=ltgray lvref=2 noframe;
symbol1 c=yellow i=join h=.5;
symbol2 c=lime i=join h=.5;

SYMBOL3 V=dot i=none repeat=11 pointlabel=(position=top j=l "#threshold") ;


axis1 order=(0 to .5 by .1) label=(a=90 c=black "Upper Confidence Limit (%)")
value=(h=1.5 '0%' '10%' '20%' '30%' '40%' '50%') minor=(number=1) color=black;
axis2 order=(10 to 120 by 10) label=(c=black "Patients Enrolled")
value=(h=1.5) minor=none color=black;
legend1 mode=share position=(inside top right) value=(c=black h=1.5
"95% CL (Alert)" "80% CL(Watch)" "Threshold")
label=none down=3 across=1;
Run;
quit;
[/PRE]

And i have finally your NOTE
normal as you have 4 5 6 7 8 who are present twice for the alpha=3

I hope i have well understand your problem.
Andre
Contributor
Posts: 29

Re: Advanced question: Proc Gplot and POINTLABEL option in Symbol statement

Wow, that's perfect! I'm so impressed, thank you so much! I'll have to look into your repeat=11 and j=l options. I'm not sure how, but they worked!
Super Contributor
Posts: 273

Re: Advanced question: Proc Gplot and POINTLABEL option in Symbol statement

the Note, following me, is comming from the number 3 which is printed on the axis
so at the limit of the data area!

j=l is only meaning left and it doesn't matter here

and the functionning of the repeat is issued from some try

as this was working
symbol3 v=dot pointlabel=("#n" c=red position=top); use of a x ou y
and even the following was not working
symbol3 v=dot pointlabel=("#alpha" c=red position=top);
so would i have luck or not?
and i tried the repeat=11 but in fact repeat=2 is working already !
The mystery in inside Sas.

Andre
Ask a Question
Discussion stats
  • 4 replies
  • 1022 views
  • 0 likes
  • 2 in conversation