BookmarkSubscribeRSS Feed
km9
Calcite | Level 5 km9
Calcite | Level 5

Hi, I'm trying to customize an effectplot stored from a MLM that I previously ran. I have two grouping variables, so I used both a sliceby and plotby statement. I am able to add a legend for my sliceby grouping variable, but I can't figure out how to for the plotby variable. It is currently coded as "Group=0" and "Group=1" but I want to change the 0 and 1 values used in the model to their descriptive meanings ("Group=Control" and "Group=Case"). Is there any way to do that? i've included my code below: 

ODS GRAPHICS / RESET HEIGHT = 4.9in WIDTH = 6.83in ;
proc sgpanel data=plot2 noautolegend;
panelby _PlotBY / novarname HEADERATTRS=(Family="times new roman" Size=11) ;
band UPPER = _UCLM LOWER = _LCLM X=_XCLAS/TRANSPARENCY=.85 group=_group
nofill;
styleattrs datacontrastcolors=(green black);
SERIES Y = _PREDICTED X=_XCLAS /group=_group ;
colaxis values= (0 to 4 by 1) label='Time' LABELATTRS=(size=11 family="times new roman") VALUEATTRS=(size=11 family="times new roman");
rowaxis grid values = (0 to 3 by 0.25) LABELATTRS=(size=11 family="times new roman") label='Predicted Mood' VALUEATTRS=(size=11 family="times new roman") GRIDATTRS=(color=GrayCA thickness=.1mm);
keylegend / title="Condition" position=bottom titleattrs=(Size=11)
valueattrs=(Family="times new roman" Size=11);
title font=timesnewroman "Fit Mood" height=11 ;
run;
4 REPLIES 4
Ksharp
Super User
That would be better if you could post your data and output graph you want to see.
ballardw
Super User

When the values in the data are like 0 and 1 and you want to display a different text then a custom format is often the easiest approach as it generally does not require any change to your data.

The below assumes that your _plotby variable is numeric and I guessed that 0 is the Control (you weren't quite specific about that)

Try:

proc format;
value _plotby
0='Control'
1='Case'
run;


proc sgpanel data=plot2 noautolegend;
panelby _PlotBY / novarname HEADERATTRS=(Family="times new roman" Size=11) ;
format _plotby _plotby. ;
band UPPER = _UCLM LOWER = _LCLM X=_XCLAS/TRANSPARENCY=.85 group=_group
nofill;
styleattrs datacontrastcolors=(green black);
SERIES Y = _PREDICTED X=_XCLAS /group=_group ;
colaxis values= (0 to 4 by 1) label='Time' LABELATTRS=(size=11 family="times new roman") VALUEATTRS=(size=11 family="times new roman");
rowaxis grid values = (0 to 3 by 0.25) LABELATTRS=(size=11 family="times new roman") label='Predicted Mood' VALUEATTRS=(size=11 family="times new roman") GRIDATTRS=(color=GrayCA thickness=.1mm);
keylegend / title="Condition" position=bottom titleattrs=(Size=11)
valueattrs=(Family="times new roman" Size=11);
title font=timesnewroman "Fit Mood" height=11 ;
run;

Note the addition of a Format statement to the Procedure code.

Appearance of values of variables is always controlled by a format of some sort in SAS. Default for most numeric values will be something like Best12, which you can check with proc contents on your data set. For a specific procedure you can override that by associating the variable with a different format.

 

If your values are actually character and not numeric the name of the format should change to $_plotby, to indicate the values are character and the 0 and 1 should also appear inside quotes in the Proc format.

jacksmith1
Fluorite | Level 6

Hello,

According to me, When using PROC SGPANEL in SAS, you can add a label for the panel variable by using the PANELBY statement and specifying the label with the PANELBYLABEL option. This helps in organizing and labeling your plots based on different categories in your data.

I hope you got the answer.

Have a nice day!

 

jacksmith1
Fluorite | Level 6

Hello,

you can try this!

ODS GRAPHICS / RESET HEIGHT=4.9in WIDTH=6.83in;
proc sgpanel data=plot2 noautolegend;
   panelby _PlotBY / novarname HEADERATTRS=(Family="times new roman" Size=11);
   band UPPER=_UCLM LOWER=_LCLM X=_XCLAS / TRANSPARENCY=.85 group=_group nofill;
   styleattrs datacontrastcolors=(green black);
   SERIES Y=_PREDICTED X=_XCLAS / group=_group;
   colaxis values=(0 to 4 by 1) label='Time' LABELATTRS=(size=11 family="times new roman") VALUEATTRS=(size=11 family="times new roman");
   rowaxis grid values=(0 to 3 by 0.25) LABELATTRS=(size=11 family="times new roman") label='Predicted Mood' VALUEATTRS=(size=11 family="times new roman") GRIDATTRS=(color=GrayCA thickness=.1mm);
   keylegend / title="Condition" position=bottom titleattrs=(Size=11)
              valueattrs=(Family="times new roman" Size=11)
              across=1;
   title font=timesnewroman "Fit Mood" height=11 ;
run;

I hope this will help you out.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 4 replies
  • 638 views
  • 2 likes
  • 4 in conversation