Data visualization with SAS programming

PROC SGPLOT: change line style

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 107
Accepted Solution

PROC SGPLOT: change line style

Dear SAS-users,

 

I would like to change the style of the lines for the section up until 2011. I would like to have dotted line instead of the filled line. HOw would I do this?

 

data graph_avg2;
input year change_cc change_ls;
datalines;
2010 100 100
2011 100 100
2012 104.050 100.98
2013 112.217 108.458

;
run;



proc sgplot data=graph_Avg2;
title  "ALL HOSPITALS- W/O MIDDLE BUCKET";
    vline year / response=change_cc lineattrs=(color=gold thickness=4) name='cc' legendlabel='Assuming 100% CC';
	vline year / response=change_ls lineattrs=(color=red thickness=4) name='ls'  legendlabel='Assuming 100% LS';

    yaxis discreteorder=data display=(noline nolabel noticks) min=80 values=(0 to 5000);
    xaxis display=(noline noticks) grid label='year' values=(2010 to 2013 by 1) offsetmin=0;
run;

Accepted Solutions
Solution
‎04-18-2018 03:20 AM
PROC Star
Posts: 1,190

Re: PROC SGPLOT: change line style

You can do something like this

 

data graph_avg2;
input year change_cc change_ls;
date=mdy(12, 31, year);
format date date9.;
datalines;
2010 100 100
2011 100 100
2012 104.050 100.98
2013 112.217 108.458
;
run;

proc expand data=graph_avg2 out=graph_avg2_expand from=year to=day;
   convert change_cc change_ls / method=join;
   id date;
run;

data graph_avg2_expand;
   set graph_avg2_expand;
   group=ifc(date>"31dec2010"d, "After", "Before");
run;

ods graphics on / attrpriority=none;
title  "ALL HOSPITALS- W/O MIDDLE BUCKET";
proc sgplot data=graph_avg2_expand noautolegend;
    styleattrs datalinepatterns=(dash solid);
    series x=date y=change_cc / group=group lineattrs=(color=gold thickness=4) name='cc' legendlabel='Assuming 100% CC';
	 series x=date y=change_ls / group=group lineattrs=(color=red thickness=4) name='ls'  legendlabel='Assuming 100% LS';

    yaxis discreteorder=data display=(noline nolabel noticks) min=80;
    xaxis display=(noline noticks) grid label='year' offsetmin=0;
run;

View solution in original post


All Replies
Super User
Super User
Posts: 9,227

Re: PROC SGPLOT: change line style

Have a look at this blog:

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

 

It has examples of every type of graph with code etc.  It is the goto for anything graph like.

 

Also a quick Google found this in the SAS help:

http://support.sas.com/kb/35/864.html

 

It is pattern you want.

Solution
‎04-18-2018 03:20 AM
PROC Star
Posts: 1,190

Re: PROC SGPLOT: change line style

You can do something like this

 

data graph_avg2;
input year change_cc change_ls;
date=mdy(12, 31, year);
format date date9.;
datalines;
2010 100 100
2011 100 100
2012 104.050 100.98
2013 112.217 108.458
;
run;

proc expand data=graph_avg2 out=graph_avg2_expand from=year to=day;
   convert change_cc change_ls / method=join;
   id date;
run;

data graph_avg2_expand;
   set graph_avg2_expand;
   group=ifc(date>"31dec2010"d, "After", "Before");
run;

ods graphics on / attrpriority=none;
title  "ALL HOSPITALS- W/O MIDDLE BUCKET";
proc sgplot data=graph_avg2_expand noautolegend;
    styleattrs datalinepatterns=(dash solid);
    series x=date y=change_cc / group=group lineattrs=(color=gold thickness=4) name='cc' legendlabel='Assuming 100% CC';
	 series x=date y=change_ls / group=group lineattrs=(color=red thickness=4) name='ls'  legendlabel='Assuming 100% LS';

    yaxis discreteorder=data display=(noline nolabel noticks) min=80;
    xaxis display=(noline noticks) grid label='year' offsetmin=0;
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 119 views
  • 0 likes
  • 3 in conversation