Reputation: 21
I am looking for syntax of most commonly used Procs for plotting Grpahs in SAS. Specifically syntax for line chart, overlay plots, bar charts, scatter plots, Tree Maps etc
Upvotes: 0
Views: 72
Reputation: 27508
Sometimes it is easier to use a UI to make a graph and then look at what the UI code generator created.
What SAS client are you using ?
Display Manager? Try Graph'n Go dm "gng" gng;
- Create a graph and export as SAS code
Enterprise Guide? Try Tasks/Graph - Create a graph and examine the code
Upvotes: 1
Reputation: 11
ods escapechar='^';
options orientation=LANDSCAPE nodate nonumber;
ods listing close;
ods pdf file="abcd.pdf"
nogfootnote nogtitle pdftoc=0;
ods noproctitle;
title;
title2;
ods pdf startpage=now;
ods proclabel = "name insights";
title h=16pt bold font='times roman' "Y1 Vs Y2";
title5 h=15pt bold font='times roman' "Name in name1";
footnote1 h=7pt font='times roman' j=r "Prepared by ABCD on date for name";
footnote2 h=7pt j=r font='times roman' 'Proprietary' font='times roman' h=8pt j=l 'Page ^{thispage}';
proc sgplot data=inputdataset(where=(var1=999));
series x = days y = yvalue1 /
legendlabel = "Y Value 1" name='y1'
lineattrs = (thickness = 3 color =cx0083be pattern = 4);
series x = days y = yvalue2 /
legendlabel = "Y Value 2"
name='y2'
lineattrs = (thickness = 2 color = brown pattern = 1);
scatter x= &x_point y=&y_point1./
legendlabel='Y Point 1' name='ypoint1'
MARKERATTRS=(symbol=diamond color=orange);
scatter x= &x_point y=&y_point2./
legendlabel='Y Point 2' name='ypoint2'
MARKERATTRS=(symbol=circle color=red);
xaxis label = "Days";
yaxis label = "Response" min=0 max=1;
keylegend 'y1' 'y2' 'ypoint1' 'ypoint2'/position=bottom across=2 down=2;
quit;
proc sgplot data=input2;
label XGroup="X Group";
histogram Response/nbins=10 group=groupvar showbins scale=COUNT;
refline &ref1/axis=x lineattrs=(color=blue) legendlabel='Ref 1' name='s_r';
refline &ref2/axis=x lineattrs=(color=red) legendlabel='Ref 2' name='r2';;
yaxis label="Count";
xaxis label="Response" max=&max.;
keylegend 'r1' 'r2'/position=bottom down=3;
quit;
proc sgpanel data=input3;
panelby panelvar;
vbar on_xaxis_var/response=y_axis_var;
run;
proc sgpanel data=input4;
panelby panelvar/onepanel skipemptycells columns=4 COLHEADERPOS=bottom NOVARNAME;
vbar on_xaxis_var/response=yvar stat=mean barwidth=0.2 fillattrs=(color=brown);
rowaxis label='Average';
colaxis label='on_xaxis_var';
run;
%let e1 = The above graph compares Y1 to ;
%let e2 = Y2 for name in name1;
title;
footnote;
ods pdf text= "^S={font_size=10pt}";
ods pdf text ="^S={just=left font=('times roman',
11pt)}&e1 &e2";
ods pdf text= "^S={font_size=10pt}";
ods pdf text ="^S={just=left font=('times roman',
11pt)}&e3 &e4 &e5 &e6 &e7";
ods pdf close;
Upvotes: 1