BookmarkSubscribeRSS Feed
KentaMURANAKA
Pyrite | Level 9

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;

20180618_1.JPG

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;

20180618_2.JPG

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.

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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:

http://support.sas.com/documentation/cdl/en/grstatproc/65235/HTML/default/viewer.htm#p0vfbphgtg4qkun...

KentaMURANAKA
Pyrite | Level 9

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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

But your not actually using the style anywhere in your code?  E.g. 

ods rtf file="..." style=mystyle;

 

You could try GTL:

https://support.sas.com/documentation/cdl/en/grstatgraph/65377/HTML/default/viewer.htm#p1li59qpc1kvg...

 

Afraid I don't even have 9.3 anymore so can't test anything.

KentaMURANAKA
Pyrite | Level 9

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. 

KentaMURANAKA
Pyrite | Level 9

Hi, RW9:

 

Sorry, I understand you don't have SAS9.3.

Thank you.

ballardw
Super User

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.

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 6 replies
  • 1313 views
  • 3 likes
  • 3 in conversation