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

Hi Folks:

 

I have two issues that I greatly appreciate your help on my SGpanel.

 

1. How to show vertical axis scales on the left and right sides of the plot as shown in the plot below?

2. How to show the value (variable 'percent') associated with the maximum of interval=60 (variable 'fu') by 'stage' and 'agegrp' so that the end of each lines (red, green and blue) in each panel will have values appear on the plot. Example shown in the panel A1 and b1 in the image below.

 

Sample data attached.

 

two labels.png

 

ods graphics/width=12in height=10in;
proc sgpanel data=four1;
panelby SORT/ novarname columns=4 rows=4;
styleattrs DATACONTRASTCOLORS=(BLUE green red);
series  x=FU y=cr/lineattrs=(pattern=solid thickness=2) GROUP=STAGE; 
colaxis label='label' min=1 max=100 grid values=(0 to 60 by 1);
rowaxis label='my-stat' 
fitpolicy=thin grid  values=(0 to 1.0 by 0.01);
keylegend/  title=" " position=top;
title ' ';
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

There are two keys for your request:

1. Use the REFTICKS option to mirror the axis.

2. Overlay another SCATTER plot using only the data points for fu=60 (see data step).

 

Here is the code:

libname local ".";

data tempfour;
set local.four1;
if fu=60 then y2=cr;
else y2=.;
run;

ods graphics/width=12in height=10in;
proc sgpanel data=tempfour;
panelby SORT/ novarname columns=4 rows=4;
styleattrs DATACONTRASTCOLORS=(BLUE green red);
series  x=FU y=cr/lineattrs=(pattern=solid thickness=2) GROUP=STAGE;
scatter x=FU y=y2/markerattrs=(size=0) datalabel=y2;
colaxis label='label' min=1 max=100 grid values=(0 to 60 by 1);
rowaxis label='my-stat' refticks=(values)
fitpolicy=thin grid  values=(0 to 1.0 by 0.01);
keylegend/  title=" " position=top;
title ' ';
run;

Hope this helps!

Dan

View solution in original post

3 REPLIES 3
DanH_sas
SAS Super FREQ

There are two keys for your request:

1. Use the REFTICKS option to mirror the axis.

2. Overlay another SCATTER plot using only the data points for fu=60 (see data step).

 

Here is the code:

libname local ".";

data tempfour;
set local.four1;
if fu=60 then y2=cr;
else y2=.;
run;

ods graphics/width=12in height=10in;
proc sgpanel data=tempfour;
panelby SORT/ novarname columns=4 rows=4;
styleattrs DATACONTRASTCOLORS=(BLUE green red);
series  x=FU y=cr/lineattrs=(pattern=solid thickness=2) GROUP=STAGE;
scatter x=FU y=y2/markerattrs=(size=0) datalabel=y2;
colaxis label='label' min=1 max=100 grid values=(0 to 60 by 1);
rowaxis label='my-stat' refticks=(values)
fitpolicy=thin grid  values=(0 to 1.0 by 0.01);
keylegend/  title=" " position=top;
title ' ';
run;

Hope this helps!

Dan

Cruise
Ammonite | Level 13

Hi @DanH_sas 

 

Thank you very much. Both issues are resolved. Any hints as to how to display percent=cr*100 instead cr itself? cr worked perfectly with  format 5.2 for two decimal places. But it didn't display when I replace cr by percent in the preceding data step with various combinations of format and datalebelpos options.

 

I appreciate any hints. 

 

set local.four1;
percent=cr*100; 
if fu=60 then y2=percent;
else y2=.;
run;

ods graphics/width=12in height=10in;
proc sgpanel data=tempfour;
panelby SORT/ novarname columns=4 rows=4;
styleattrs DATACONTRASTCOLORS=(BLUE green red);
series  x=FU y=cr/lineattrs=(pattern=solid thickness=2) GROUP=STAGE;
scatter x=FU y=y2/markerattrs=(size=0) datalabel=y2;
colaxis label='label' min=1 max=100 grid values=(0 to 60 by 1);
rowaxis label='my-stat' refticks=(values)
fitpolicy=thin grid  values=(0 to 1.0 by 0.01);
keylegend/  title=" " position=top;
title ' ';
format y2 5.2; run;
DanH_sas
SAS Super FREQ

The VALUES option on the ROWAXIS statement might conflict with PERCENT being assigned to Y2. Make sure your "* 100" is factored into your tick value list.

 

Thanks!
Dan

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!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1299 views
  • 1 like
  • 2 in conversation