Graphics Programming

Data visualization using SAS programming, including ODS Graphics and SAS/GRAPH. Charts, plots, maps, and more!
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Manj
Fluorite | Level 6

Hi, I using the following code to build the plot attached. I would need to change the attributes of the lines to pink solid line and green dashed line. At present it is showing blue and red solid lines be default. Anyone suggest a method to change the attributes? 

 

ods listing close;
ods pdf file="&g_outfile..&g_fontsize" nobookmarkgen style=idsl dpi=600 ;

ods noproctitle ;


title1 j=l height=10pt "Protocol: %upcase(&g_study_id)" j=r "Page 1 of 1";
title2 j=l height=10pt "Population: &g_poplbl";
title3 j=center "Figure &g_dsplynum";
title4 j=center "&g_title1 ";
title5 %if &g_title2 = %then %do; color = white "." %end; %else %do; j=center "&g_title2." %end;;


*footnote1 j=left h=9pt "&g_foot1";
Footnote1 j=left h=9pt j=left "&g_userid: &g_pgmpth &sysdate9 &systime";


proc univariate data=sf36_obs noprint ;
class trtppn ;
var chg;
cdfplot /overlay odstitle=none ;
run;


ods pdf close;
ods listing;

 

 

Manj_0-1615827700891.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

You can do it by changing the ODS style, but many people find it easier to use ODS OUTPUT to write the data underlying the graph to a SAS data set, and then use PROC SGPLOT to customize the graph.

 

To get the pink/green and line styles, make sure you are using AttrPriority=None on the ODS GRAPHICS statement. You can then use the STYLEATTRS statement to specify the line colors and patterns, as follows:

 

data A;
set sashelp.cars;
where origin in ('USA' 'Asia');
run;

proc univariate data=A noprint ;
class origin;
var mpg_city;
cdfplot /overlay odstitle=none ;
ods output CDFPlot = OutCDF;
run;

ods graphics / AttrPriority=None;
title "My CDF Plot";
proc sgplot data=outCDF noautolegend;
   styleattrs DATACONTRASTCOLORS=(Pink DarkGreen) DATALINEPATTERNS=(solid dash);
   step x=ECDFX y=ECDFY / group=Class1; /* variable names created by PROC UNIVARIATE */
   xaxis grid;
   yaxis grid min=0 label="Cumulative Proportion";
run;

View solution in original post

3 REPLIES 3
Rick_SAS
SAS Super FREQ

Is this for a class?

Rick_SAS
SAS Super FREQ

You can do it by changing the ODS style, but many people find it easier to use ODS OUTPUT to write the data underlying the graph to a SAS data set, and then use PROC SGPLOT to customize the graph.

 

To get the pink/green and line styles, make sure you are using AttrPriority=None on the ODS GRAPHICS statement. You can then use the STYLEATTRS statement to specify the line colors and patterns, as follows:

 

data A;
set sashelp.cars;
where origin in ('USA' 'Asia');
run;

proc univariate data=A noprint ;
class origin;
var mpg_city;
cdfplot /overlay odstitle=none ;
ods output CDFPlot = OutCDF;
run;

ods graphics / AttrPriority=None;
title "My CDF Plot";
proc sgplot data=outCDF noautolegend;
   styleattrs DATACONTRASTCOLORS=(Pink DarkGreen) DATALINEPATTERNS=(solid dash);
   step x=ECDFX y=ECDFY / group=Class1; /* variable names created by PROC UNIVARIATE */
   xaxis grid;
   yaxis grid min=0 label="Cumulative Proportion";
run;
Manj
Fluorite | Level 6

Thanks. It worked well.

sas-innovate-white.png

Join us for our biggest event of the year!

Four days of inspiring keynotes, product reveals, hands-on learning opportunities, deep-dive demos, and peer-led breakouts. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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
  • 3 replies
  • 3735 views
  • 1 like
  • 2 in conversation