BookmarkSubscribeRSS Feed
petem
Calcite | Level 5

Hi ,

I need a series plot with xaxis=subject and yaxis=risk with treatment groups a ,b and each subject has again different ht percentiles. so i need to plot 2nd percentile on the graph with red color(dotted pattern will be for trt=a and solid pattern for trt=b) and like wise 3rd percentile on graph with blue color(dotted pattern for trt=a, solid pattern for trt=b) and 4th percentile with orange color(dotted pattern for trt=a , solid pattern for trt=b). and i need to show legends as  red=2nd percentile,blue=3rd percentile,orange=4th percentile,dotted line with no color as trt a, solid line with trt b.

so basically i need to show series plot of different percentile vs trt group.

SUBJ TRT RISK PERCENTILE

101  a       1.1       2nd percentile

101  a       1.2       3rd percentile

101  a       1.3       4th percentile

102  b       1.4       2nd percentile

102  b        1.3       3rd percentile

102  b        1.2       4th percentile

do i need to create 3 variable as var1,var2,var3 for 3 different percentiles because legends are not showing up

proc sgplot data=test;

series xaxis=subj yaxis=var1/ group=trt name='a';

series xaxis=subj yaxis=var2/ group=trt name='b';

series xaxis=subj yaxis=var3/ group=trt name='c';

keylegend 'a' 'b' 'c'

run;

above is sample code. keylegend just has short code.

even if i do this i am not able to create proper legend or do i need to create var1 to var6 (var1 to var3 for trt=a, var4 to var6 for trt=b) and then create colors to line and legend.

please advice?

thanks,

vk

2 REPLIES 2
Jay54
Meteorite | Level 14

Yes, you can do this using the LineColorGroup and LinePatternGroup options in the GTL SeriesPlot.  You can plot risk by subject with group=percentile.  However, your data is off a bit, you need trt to be same across a line.  Here is the graph and code:

PowerSeries.png

data values;

  input SUBJ $ TRT $ RISK PERCENTILE $14-27;

  datalines;

101  a  1.1  2nd percentile

101  a  1.2  3rd percentile

101  b  1.3  4th percentile

102  a  1.4  2nd percentile

102  a  1.3  3rd percentile

102  b  1.2  4th percentile

run;

proc template;
  define statgraph PowerSeries;
    begingraph;
      layout lattice;
        layout overlay;
          seriesplot x=subj y=risk / group=percentile
             linecolorgroup=percentile linepatterngroup=trt name='a';
        endlayout;
        sidebar / align=bottom spacefill=false;
          layout gridded / columns=2;
            discretelegend 'a' / title='Trt:' type=linepattern across=2;
            discretelegend 'a' / title='Percentile:' type=linecolor across=3;
          endlayout;
       endsidebar;
     endlayout;
     endgraph;
  end;
run;

ods listing;
ods graphics / reset width=5in height=3in imagename='PowerSeries';
proc sgrender data=values template=PowerSeries;
run;

petem
Calcite | Level 5

Thanks sanjay. This is what i need.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

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
  • 2 replies
  • 1616 views
  • 0 likes
  • 2 in conversation