在SAS中绘制图形的一般语法

时间:2018-10-02 14:33:30

标签: sas

我正在寻找用于在SAS中绘制Grpah的最常用Procs的语法。折线图,重叠图,条形图,散点图,树形图等的具体语法

2 个答案:

答案 0 :(得分:1)

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;

答案 1 :(得分:1)

有时,使用UI制作图形然后查看UI代码生成器创建的内容会更容易。

您正在使用什么SAS客户端?

显示管理器?尝试Graph'n Go dm "gng" gng;   -创建图形并导出为SAS代码

企业指南?尝试任务/图表   -创建图形并检查代码