SAS 数据集输出到EXCEL 代码

%macro printoutexcel(lib=);        
    
%let today   = %upcase(&SYSDATE9.);
%let todayt  = %sysfunc(today(),yymmddn8.)T%sysfunc(compress(&systime.,:));
 

data dts;
  set sashelp.vtable (where=(libname=upcase("&lib"))) ;  
run;

proc sql noprint;
    select memname, memlabel into :l_dsets separated by '|', :l_dslabels separated by '|'
    from dts;
quit;


ods listing close;

        ods excel
        %if %upcase(&lib)=OUTPUTDM %then %do;
        file="&root.\QC\EditChecks\&protocol EditCheck listings_&todayt..xlsx"
        %end;
        %else %if %upcase(&lib)=COMPARE %then %do;
            file="&root.\QC\DataListings\&protocol compare_&datesp..xlsx"
        %end;
            %else %if %upcase(&lib)=OUTPUT %then %do;
          file="&root.\QC\DataListings\&protocol mm listings_&todayt..xlsx"
        %end;
        %else %if %upcase(&lib)=OUTPUTPM %then %do;
          file="&root.\QC\DataListings\&protocol pm listings_&todayt..xlsx"
        %end;
        %else %do;
          file="&root.\QC\DataListings\&protocol dm listings_other&todayt..xlsx"
        %end;

        STYLE=excel                                
        options(Embedded_Titles="yes"
                center_horizontal = "yes"
                orientation= "landscape"
                fittopage = "yes"
                autofilter="all"
                row_repeat = "1-3"
                frozen_headers= ""
                flow='tables'
                formulas='on'
                index="on");           
 
%let i=1;
%let l_dset=%scan(&l_dsets,&i,|);
%let l_dslabel=%scan(%bquote(&l_dslabels),&i,|);
 
%do %while ( &l_dset ^= () );
    ods excel options(sheet_name="&l_dset." );

    PROC REPORT  DATA=&LIB..&l_dset nowd headline  headskip split='|' missing 
    Style(header)=[  cellspacing = 3  
                     borderwidth = 2
                     bordercolordark = black 
                     background=grey 
                     foreground=white 
                     just=center
                     vjust=center
                     ]
    Style(column)=[  cellspacing = 3  
                     borderwidth = 2 
                     bordercolordark = black 
                     background=white 
/*                    just=center*/
                     vjust=center  
                       ]
                                   ;
    define _all_         / style(column)={tagattr='format:@  '};
    define _char_       /style(column)={tagattr='type: char '};
    RUN;
      
%let i=%eval(&i+1);
%let l_dset=%scan(&l_dsets,&i,|);
%let l_dslabel=%scan(%bquote(&l_dslabels),&i,|);
%end;

ods excel close; 
ods listing; 
%mend;

全部评论

相关推荐

程序员牛肉:1.大头肯定是院校问题,这个没啥说的。 2.虽然有实习,但是实习的内容太水了,在公司待了七个月的时间,看起来就只做了jwt和接入redis。爬取新闻,数据导入。这几个需求值得你做七个月吗?这不就是三四个月的工作量吗?我要是面试官的话真心会认为你能力不太行。所以既然有实习了,一定要好好写,像是Swagger这种东西是真没必要写上去,就拉一个包的事情。 3.我个人觉得话,在校生不要把自己当社招看,除非你的项目是特别牛逼,特别有名的含金量,否则不要写这种密密麻麻的一串子工作职责。你的项目只有一个作用,就是供面试官从中来抽取八股对你进行拷打。 但是你现在这个看不来什么技术点,可以改一下,详细表述一下你用什么技术实现了什么功能,在实现这个功能的过程中,你解决了什么难题。
点赞 评论 收藏
分享
昨天 15:39
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务