将sas dataset 导出至Excel格式

ods excel file="&filepath..xlsx"
  options(
    absolute_column_width='none'      /*列宽*/
    absolute_row_height='20'              /*行高*/
    center_horizontal= 'off'         
    center_vertical= 'off'
    embed_footnotes_once='yes'        /*添加脚注*/
    embedded_titles='on'                    /*添加title*/
    frozen_headers='on'                     /*首行冻结*/
    gridlines='off'                                /*关闭网格线*/
    rowcolheadings='on'                     /*显示每个变量的label为表头*/
    sheet_name="事件"                      /*将sheet命名*/
    );

title "列表";
footnote "*日期";

proc report data=final nowd;
column col1-col21;
run;
ods excel close;

 

来自网友Fiona33322的代码:

proc template;
define style styles.test;
parent=styles.sasweb;
replace document from container /
protectspecialchars =off
;
end;
run;
title;
ods noproctitle;
ods listing close;
ods results off;
ods excel file="&root\output\medical review_&date..xlsx" style=styles.test;

ods excel options(  sheet_interval='none' suppress_bylines='no' embedded_titles='yes' sheet_interval='none'
sheet_name="表3-1)AE计数表"
/*                                   absolute_column_width='15'  */
                                   gridlines='yes'  autofilter='yes'
                                   frozen_headers='0' embedded_titles='yes');
  proc report data=mrf.t31 split="|" style(report)={tagattr='WRAP:NO'} style={protectspecialchars=off } ;
  run;
ods excel close;
ods listing;
ods results;

 

来自网友可~乐~的代码:

proc template;
        define style formatSTYLE;

     parent = Styles.Listing; 
                STYLE SystemTitle /
                FONT_FACE = "Times New Roman"
                FONT_SIZE = 2.5
                FONT_STYLE = roman
                FOREGROUND = black
                BACKGROUND = white;
        STYLE Header /
                BACKGROUND = white
                FOREGROUND = blcak
                FONT_FACE = "Times New Roman"
                FONT_STYLE = roman
                JUST = center
                VJUST = middle
                FONT_SIZE = 2.5;
        STYLE Cell /
                BACKGROUND = white
                FOREGROUND = black
                FONT_FACE = "Times New Roman"
                FONT_WEIGHT = light
                FONT_STYLE = roman
                JUST = center
                VJUST = middle
                FONT_SIZE = 2.5;
        STYLE Table /
                RightMargin=3.17cm
                LeftMargin=3.17cm
                TopMargin=2.54cm
                BottomMargin=2.54cm
                CELLSPACING = 0
                CELLPADDING = 2
                FRAME = void
                RULES = none

                OUTPUTWIDTH = 925;
        end;
run;

posted @ 2020-12-04 17:34  yangqin123  阅读(1074)  评论(0)    收藏  举报