Hi, All:
I have data like the following code, which have Estimate Value with lower & upper CL per Treatment per TimePoint.
data test;
input trtn time lower estimate upper;
datalines;
1 1 0.1 0.15 0.3
1 2 6.5 7 8.5
1 3 8 9.2 10
1 4 7.5 8.5 9
1 5 6.5 7 7.4
1 6 3.5 4.2 4.5
1 7 2.1 2.3 2.7
1 8 1.9 2 2.1
1 9 1.5 1.7 1.9
1 10 1.4 1.5 1.8
2 1 1.1 1.15 1.3
2 2 7.5 8 9.5
2 3 9 10.2 11
2 4 8.5 9.5 10
2 5 7.5 8 8.4
2 6 4.5 5.2 5.5
2 7 3.1 3.3 3.7
2 8 2.9 3 3.1
2 9 2.5 2.7 2.9
2 10 2.4 2.5 2.8
3 1 2.1 2.15 2.3
3 2 8.5 9 10.5
3 3 10 11.2 12
3 4 9.5 10.5 11
3 5 8.5 9 10.4
3 6 5.5 6.2 6.5
3 7 4.1 4.3 4.7
3 8 3.9 4 4.1
3 9 3.5 3.7 3.9
3 10 3.4 3.5 3.8
;
run;
Using this data, I want to make time-series graph, and I got my objective using SAS9.4.
ods listing gpath="YourFilesAddress";
ods graphics on / reset
imagename="YourFileName" imagefmt=emf border=off
width=6in height=6in
attrpriority=none;
proc sgplot data=test noautolegend;
styleattrs datalinepatterns=(solid)
datacontrastcolors=("lime" "purple" "red")
datasymbols=("circlefilled" "trianglefilled" "squarefilled");
scatter x=time y=estimate / group=trtn yerrorlower=lower yerrorupper=upper;
series x=time y=estimate / name="series" group=trtn lineattrs=(pattern=1) markers markerattrs=(size=0.1in);
keylegend "series" / noborder location=outside position=bottomleft across=3 down=1;
run;
I want graph with 3 combinations (Lime&circlefilled, purple&trianglefilled, Red&squarefilled), and I want to use SAS9.3, instead of SAS9.4.
In SAS9.3, I probably can't use ATTRSPRIORITY= & STYLEATTRS.
So I wrote the code below, and using SAS9.3 & %MODSTYLE, I got this result.
%modstyle(parent=listing, name=mystyle,
colors=lime purple red, markers=circlefilled trianglefilled squarefilled, linestyles=1);
ods listing gpath="YourFilesAddress" style=mystyle;
ods graphics on / reset
imagename="YourFileName" imagefmt=emf border=off
width=6in height=6in
/*attrpriority=none*/;
proc sgplot data=test noautolegend;
/* styleattrs datalinepatterns=(solid)*/
/* datacontrastcolors=("lime" "purple" "red")*/
/* datasymbols=("circlefilled" "trianglefilled" "squarefilled");*/
scatter x=time y=estimate / group=trtn yerrorlower=lower yerrorupper=upper;
series x=time y=estimate / name="series" group=trtn lineattrs=(pattern=1) markers markerattrs=(size=0.1in);
keylegend "series" / noborder location=outside position=bottomleft across=3 down=1;
run;
This result is not my wanted (colors are good, but all symbols are circles).
I want to accomplish 3CombinationGraph. Please help me.
Thank you for advance.
If you have SAS 9.4 and code which works correctly, why would you want to use 9.3 and re-factor the code?
Yes you can't use styleattrs in 9.3, it was introduced in 9.4.
What would be simplest is just to modify the style used and fix in your colors/symbols:
https://blogs.sas.com/content/sgf/2014/05/30/assigning-graph-style-attributes-easily/
You could also set symbols on the markerattrs statement:
Hi, RW9:
Thanks to information you gave me, I got closer to my objective, I feel.
But my code below, in which TEMPLATE Procedure is used, gave me same one as my previous second photo.
I can't find why only colors are changed & symbols are all circlefilled.
Please give me advice. Thank you.
proc template;
define style mystyle;
parent=styles.htmlblue;
class graphdata1 /
contrastcolor=lime linestyle=1 markersymbol='circlefilled';
class graphdata2 /
contrastcolor=purple linestyle=1 markersymbol='trianglefilled';
class graphdata3 /
contrastcolor=red linestyle=1 markersymbol='squarefilled';
end;
run;
ods listing gpath="YourFilesAddress";
ods graphics on / reset
imagename="YourFileName" imagefmt=emf border=off
width=6in height=6in
;
proc sgplot data=test noautolegend;
scatter x=time y=estimate / group=trtn yerrorlower=lower yerrorupper=upper;
series x=time y=estimate / name="series" group=trtn lineattrs=(pattern=1) markers markerattrs=(size=0.1in);
keylegend "series" / noborder location=outside position=bottomleft across=3 down=1;
run;
Reason I have to use SAS9.3 depends on my condtion. I'm sorry,but I want to accomplish my objective using SAS9.3.
But your not actually using the style anywhere in your code? E.g.
ods rtf file="..." style=mystyle;
You could try GTL:
Afraid I don't even have 9.3 anymore so can't test anything.
Hi, RW9:
Sorry, my mistake of copying.
Of course, I used STYLE=mystyle in my previous code, but I didn't get my wanted.
Can you get it by using this code?
SGRNDER Procedure, I'll try it, but I want to know how I can get it using the code I gave.
Hi, RW9:
Sorry, I understand you don't have SAS9.3.
Thank you.
With the scatter and series statements investigate the MARKERATTRS= option to set marker symbol and colors.
Or look into DATTRMAP for a discrete attribute map for values.
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!
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.