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

Hello,

I have a plot that I'm creating using longitudinal data from 15 patients. Each patient is followed up for at most 7 time points. Each patient can belong into one of three groups. I can create the graph where patients in similar groups will have the same color and line patterns. However, I cannot seem to assign the legend labels properly. To further describe the creation of the plot, I created individual columns for each of the three groups. Some rows will be blank, of course, since some patients will be in other groups. I used sgrender to plot x = time and y = value BY PT. This got me the individual curves for each of the 15 patients. However, in doing this, SAS assigns a legend item to each patient, when I really want to assign only 3 categories defined by each GROUP. Is there a fix for this?

Thanks!

Here is what I have so far:

SGRender129.png

The code used to generate this is:

proc template;

define statgraph sgplot1;

begingraph /;

layout overlay / xaxisopts=(label = "Follow-up period" linearopts = (viewmax=7.7 tickvaluelist=(1 2 3 4 5 6 7))) yaxisopts=(linearopts=(viewmin=0)) ;

   SeriesPlot X=time Y=level1val / display = all primary=true Group=pt lineattrs = (Color=CX008000 pattern=20) Markerattrs=( Color=CX008000 Symbol=ASTERISK)  LegendLabel="Level 1" NAME="Dose";

   SeriesPlot X=time Y=level2val / display = all Group=pt lineattrs = (Color=CX000000 pattern=1) Markerattrs=( Color=CX000000 Symbol=CIRCLE)  LegendLabel="Level 2" NAME="Dose";

   SeriesPlot X=time Y=level3val / display = all Group=pt lineattrs = (Color=CXFF0000 pattern=2) Markerattrs=(Color=CXFF0000 Symbol=TRIANGLE)  LegendLabel="Level 3" NAME="Dose";

   beginpolyline x = 7.4 y = 1.27/drawspace = datavalue lineattrs=(color=CX000000 thickness=1.5);

    draw x = 7.5 y = 1.27/drawspace = datavalue;

  draw x = 7.5 y = 0.64/drawspace = datavalue;

  draw x = 7.4 y = 0.64/drawspace = datavalue;

   endpolyline;

   drawtext  textattrs=(size = 9pt) "0.64" /x = 7.5 y = 0.60 drawspace = datavalue;

   drawtext  textattrs=(size = 9pt) "1.27"/x = 7.5 y = 1.30 drawspace = datavalue;

endlayout;

endgraph;

end;

run;

proc sgrender template = sgplot1 data = creat;

run;

Thanks,

John

1 ACCEPTED SOLUTION

Accepted Solutions
JohnPura
Calcite | Level 5

Thank you everyone for chiming in. Ultimately I found my answer in another post - https://communities.sas.com/message/141826#141826.

View solution in original post

5 REPLIES 5
ballardw
Super User

Code you used would help.

data_null__
Jade | Level 19

Data would help too.  The GTL experts may be able to tell you what you need just by looking at your code but it always helps to have a complete working (or not working) program with data.

DanH_sas
SAS Super FREQ

The problem is that the plot reports back the group information to the legend, while your desired result is to have each series (without group) in the legend. There are some possible solutions, but I need to know the version of SAS you're using to give you the correct solution.

data_null__
Jade | Level 19

I have done similar using BREAK option where I "spaghetti plot" subjects in normal range groups, Normal or High (with legend for range group), by adding an observation between each subject with missing values for the plot variables.  This makes a separate line for each subject with attributes of the normal range groups.

BREAK=boolean

breaks the plot line at missing values of the X or Y variable.

JohnPura
Calcite | Level 5

Thank you everyone for chiming in. Ultimately I found my answer in another post - https://communities.sas.com/message/141826#141826.

sas-innovate-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

Plus, pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 2797 views
  • 0 likes
  • 4 in conversation