- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi All
I am trying to draw graphs using the proc sgplot with the group option. SAS provides me with automatic colours and I need to choose my own preferred colours. the program I use is as below and data attached.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @mmohotsi,
A simple solution is to add a STYLEATTRS statement to the PROC SGPLOT step and to specify the group colors in the DATACONTRASTCOLORS= option.
Example:
proc sgplot data=Tested3; styleattrs datacontrastcolors=(lime gray purple skyblue); vline Dates / response=Amount group=sampling_point groupdisplay=overlay ; ...
See Color-Naming Schemes for the various ways to specify colors (e.g., by RGB values).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
For which elements of your graph do you want to specify colors?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I wish to draw trend line for amount and group by sampling_point with Dates on the horizontal axis
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @mmohotsi,
A simple solution is to add a STYLEATTRS statement to the PROC SGPLOT step and to specify the group colors in the DATACONTRASTCOLORS= option.
Example:
proc sgplot data=Tested3; styleattrs datacontrastcolors=(lime gray purple skyblue); vline Dates / response=Amount group=sampling_point groupdisplay=overlay ; ...
See Color-Naming Schemes for the various ways to specify colors (e.g., by RGB values).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
That's the solution to my problem
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Good day
Solution accepted
Thanks to you FreelanceReinh Jade
Much appreciated
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you want graphs to display the same properties, colors, markers, line types for example based on the VALUE of a group variable then you likely want to investigate the use of DATTRMAP= helper data set.
Other approaches using the same style lists can display the same value with different colors based on the order of the data.
Here is an example to demonstrate the order of values encountered can affect the color usage:
data work.class; set sashelp.class; run; proc sort data=work.class; by sex; run; proc sgplot data=work.class; title "Sorted by Sex"; styleattrs datacontrastcolors=(Red blue); scatter x=height y=weight/group=sex; run;title; proc sort data=work.class; by descending sex; run; proc sgplot data=work.class; title "Sorted by descending Sex"; styleattrs datacontrastcolors=(Red blue); scatter x=height y=weight/group=sex; run;title;
@mmohotsi wrote:
Hi All
I am trying to draw graphs using the proc sgplot with the group option. SAS provides me with automatic colours and I need to choose my own preferred colours. the program I use is as below and data attached.
proc sgplot data=Tested3;vline Dates / response=Amount group=sampling_point groupdisplay=overlay ;yaxis values=(0 to 3000 by 30000) label='Free Chlorine' grid LABELATTRS=(weight=bold family=Helvetica size=7)VALUEATTRS=(family=Helvetica size=7 style=normal weight=normal ) ;refline 9500 / axis=y label=('9500 expected') lineattrs=(color=red pattern=dash) labelattrs=(size=7) labelloc=inside;xaxis interval=day VALUESROTATE=VERTICAL label='Sampled dates' LABELATTRS=(weight=bold size=7) valuesrotate=verticalVALUEATTRS=(family=arial size=10 style=normal weight=normal ) type=time;title1 j=c "Expenditure trend" bold;run;