I am using SAS 9.3, and using the following link as an example: SAS/STAT(R) 9.2 User's Guide, Second Edition.
Suppose that I have another variable, called status (say, negative and positive), is it possible to use different colors for the Output 92.3.4 Profiles over Treatments, i.e, those blue lines now will have colors based on status? Thanks a lot!
You can use the code below to get the plot that you're after. The code below rearranges the format of the data so that GTL can be used to plot the data.
The only word of caution is that it seems that you are going from a paired t-test to a general linear model (by including Status), and therefore you probably should use Proc GLM or Proc Mixed instead of Proc tTest when analysing your factors.
/* Creating paired relationship and dummy status */
paired_id = _n_;
if _n_ <= 6 then statusn = 1;
else statusn = 2;
/* Stacking the data */
proc transpose data = pressure2 out = pressure_trans;
by paired_id statusn;
var SBPbefore SBPafter;
/* Calculating Mean Value */
create table pressure_trans2 as
select *, avg(col1) as means
group by _NAME_
order by _NAME_ desc, statusn;
define statgraph profiles;
discreteattrmap name="symbols" /; /* Creating Legend attributes */
value "Negative" / lineattrs=(color=GraphData1:color); /* Negative maps to value 1 of StatusN because 1 is the first one */
value "Positive" / lineattrs=(color=GraphData2:color);
layout overlay /xaxisopts=(type=discrete display=(line ticks tickvalues) offsetmin=autocompress offsetmax=
yaxisopts = (display = (line ticks tickvalues)) y2axisopts =(display=(line ticks tickvalues));
seriesplot x = _NAME_ y = col1 / group = paired_id index = statusn datatransparency = 0.1 lineattrs = (pattern = 1); /* Using group = paired_id to obtain the seperate line for each subject */
seriesplot x = _NAME_ y = col1 / yaxis=y2 group = paired_id index = statusn datatransparency = 0.1 lineattrs = (pattern = 1); /* Displaying secondary axis */
seriesplot x = _NAME_ y = means / lineattrs=(pattern=GraphFit2:LineStyle color=black thickness=3); /* Plot of the means */
discretelegend "symbols" / type = line;
goptions reset = all; /* Getting rid of any previous titles and footnotes */
proc sgrender data = pressure_trans2 template = profiles ;
Sorry for the late response, I was busy doing another project.
Thank you very much for the sample code. It works, but not exactly what I have hoped. I was really hoping that we can change the color more easily in SAS. Thank you for those cautious words too, I am fully aware of that; I can't say more, but the big boss just want to "see" it that way.
That's fine JessicaVan.
I'm glad it helped. Yes, I believe it's not that easy because when using the paired option in Proc Ttest, is doesn't expect someone to use another variable.
I also looked into updating the pairedplot template, however it didn't seem like it was possible for the template to use another variable.
Do you need to use another color in your plots? If so, instead of using color=GraphData1:color and color=GraphData2:color, you could just use color=red or color = blue and so on.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.