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

Hello,

I have the following syntax:

proc gplot data=DM_Work.All_Rates;

plot ir*time=testrx / vaxis = axis1 haxis=axis2

legend=legend1;

run;

I would like to specify the colour for the grouping variable TestRX.  TestRX groups treated  v untreated.  I am not sure how to make one line blue and one line red.

Any help with the syntax would be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
lisahoward
Calcite | Level 5

Hi do you know if It is possible to combine my proc template and the macro ?

proc template;

  define style myfont;

  parent=styles.default;

   style GraphFonts /

           'GraphFootnoteFont' = ("Arial",10pt,bold)

         'GraphTitleFont' = ("Arial",6pt,bold)

         'GraphValueFont' = ("Arial",8pt)

   'GraphAnnoFont' =("Arial", 10pt)

          'GraphUnicodeFont'=("Arial", 10pt)

          'GraphLabelFont'=("Arial", 10pt)

          'GraphDataFont'=("Arial", 10pt);

   end;

run;

and

%modstyle(

parent=statistical,

name=plotmod,

type=CLM,

colors=red blue,

fillcolors=colors,

markers=triangefilled circlefilled

);

View solution in original post

12 REPLIES 12
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Move over to using proc sgplot and proc template, they will give you more controll over your output:

35864 - Change line colors and styles for PROC SGPLOT output

ballardw
Super User

If you want to continue to use GPLOT then the statement that provides control over lines and markers is SYMBOL.

Symbol1 color=red I=join;

symbol2 color=blue I=join;

Place these before the gplot statement.

The first value of TestRX encountered will get the characteristics set in the first symbol statement.

lisahoward
Calcite | Level 5

Hi I decided et go with Sgplot and use the code below:

proc sgplot data=DM_Work.All_Rates;

         series x=TIME y=IR / group=TestRx markers lineattrs=(pattern=solid ) ;

           REFLINE 1 2 3 4  ;

   XAXIS TYPE = DISCRETE;
   yaxis label = 'AMI Rate per 1000' ;

           xaxis label = 'Time in Days ' grid values = (-360 to 360 by 30);

run

However I want to change the markers so they are filled triangle and filled Circle.  How do I do this when using the group = option ?

Many thanks in advance.

Lucy

djrisks
Barite | Level 11

Hi Lucy, what version of SAS have you got?

Thanks.

lisahoward
Calcite | Level 5

9.2.

I am also trying to figure out how to get minor tick marks on the horizontal axis and rotate the label on the vertical access.

Many thanks in advance, SAS graph is new to me Smiley Happy

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Your best bet is to have a look through Sanjay's blog at:

http://blogs.sas.com/content/graphicallyspeaking/

He has working examples for most versions of pretty much everything graph wise.  Its better than the documentation.

djrisks
Barite | Level 11

Because you have SAS 9.2, I would use the %modstyle macro to change your markers. Such as this below:

%modstyle(

parent=statistical,

name=plotmod,

type=CLM,

colors=red blue,

fillcolors=colors,

markers=triangefilled circlefilled

);

You can then call the updated template by using ods listling style = plotmod; (or even ods html style = plotmod;) before your Proc SGPLOT.

For documentation on the %modstyle macro go to here:

SAS/STAT(R) 9.22 User's Guide

I thought the tickmarks and ticklabels would automatically be in the format you wanted them?

lisahoward
Calcite | Level 5

great thank you for your help.  I wanted to use minor tickmarks on the horizontal axis and offset the graoh slighty on the left so there was some space between the  graph and the border but I am unsure how to do this.  In terms of the label on the vertical axess i would like to rotate it 90 degrees but again am unsure of the syntax.I will take a look at the blog mentioned above to see if I can find the answer.  thank you again for all your help.

lisahoward
Calcite | Level 5

Hi do you know if It is possible to combine my proc template and the macro ?

proc template;

  define style myfont;

  parent=styles.default;

   style GraphFonts /

           'GraphFootnoteFont' = ("Arial",10pt,bold)

         'GraphTitleFont' = ("Arial",6pt,bold)

         'GraphValueFont' = ("Arial",8pt)

   'GraphAnnoFont' =("Arial", 10pt)

          'GraphUnicodeFont'=("Arial", 10pt)

          'GraphLabelFont'=("Arial", 10pt)

          'GraphDataFont'=("Arial", 10pt);

   end;

run;

and

%modstyle(

parent=statistical,

name=plotmod,

type=CLM,

colors=red blue,

fillcolors=colors,

markers=triangefilled circlefilled

);

djrisks
Barite | Level 11

Hi Lucy,

Yes you can combine the proc template and the %modstyle macro by using parent=myfont in the %modstyle macro, which will reference the template that you have created instead of the STATISTICAL style.

Okay yes, I will try to look at your other questions later if you haven't found a solution by then.

Thanks.

PS you could have also changed the colours of your groups solely by using Proc Template too.

lisahoward
Calcite | Level 5

great thank you.

djrisks
Barite | Level 11

That's fine. Can you please mark some of the responses to your questions as Correct Answers or Helpful Answers were appropriate?

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 12 replies
  • 2823 views
  • 6 likes
  • 4 in conversation