我正在尝试动态生成和导出条形图和excel工作簿。 My Macro拉出某些不同的标识符代码,并为每个相应的ID创建两个汇总表(prov_& x table和prov_revcd_& x)并填充到单个excel表。但是,我无法成功生成数据的条形图并导出到Excel。下面是代码的精简版本。我已经删除了创建prov_& x表和prov_revcd_& x表的步骤,以帮助使帖子尽可能简洁。我已经尝试使用GOUT函数和NAME函数,然后显式调用那些但似乎不起作用。欢迎任何建议,我理解我的宏代码有点草率,但它生成表格,所以我会清理一旦我可以生成条形图。
另外,我可以在结果查看器中看到图形正在生成,所以我假设问题在于我是如何尝试将它们引用到工作簿中的。谢谢!
%macro runtab(x);
/*Create summary chart for generating graph of codes billed per month*/
proc sql;
CREATE TABLE summary_&x AS
select DISTINCT month, COUNT (CH_ICN) AS ICN_Count, CLI_Revenue_Cd_Category_Cd
FROM corf_data1_sorted
WHERE BP_Billing_Prov_Num_OSCAR=&x
group by month ,CLI_Revenue_Cd_Category_Cd;
run;
/*Create a graph of Services Per Month and group by the Revenue Code*/
proc sgplot data=summary_&x NAME= 'graph_&x';
title 'Provider Revenue Analysis';
vbar month / response=ICN_count group=CLI_Revenue_Cd_Category_Cd stat=sum
datalabel datalabelattrs=(weight=bold);
yaxis grid label='Month';
run;
%mend runtab;
/*Create a macro variable of all the codes */
proc sql noprint;
select BP_Billing_Prov_Num_OSCAR
into :varlist separated by ' ' /*Each code in the list is sep. by a single space*/
from provider;
quit;
%let cntlist = &sqlobs; /*Store a count of the number of oscar codes*/
%put &varlist; /*Print the codes to the log to be sure our list is accurate*/
/*write a macro to generate the output tables*/
%macro output(x);
ods tagsets.excelxp options(sheet_interval='none' sheet_name="&x");
proc print data=prov_&x;
run;
proc print data=prov_revcd_&x;
run;
proc print data=graph_&x;
run;
%mend;
/*Run a loop for each oscar code. Each code will enter the document generation loop*/
%macro loopit(mylist);
%let else=;
%let n = %sysfunc(countw(&mylist)); /*let n=number of codes in the list*/
data
%do I=0 %to &n;
%let val = %scan(&mylist,&I); /*Let val= the ith code in the list*/
%end;
%do j=0 %to &n;
%let val = %scan(&mylist,&j); /*Let val= the jth code in the list*/
/*Run the macro loop to generate the required tables*/
%runtab(&val);
%output(&val);
%end;
run;
%mend;
/*Run the macro loop over the list of significant procedure code values*/
ods tagsets.excelxp file="W:\user\test_wkbk.xml";
%loopit(&varlist)
ods tagsets.excelxp close;
答案 0 :(得分:1)
不幸的是,您无法使用ODS TAGSETS.EXCELXP
导出图表。
如果您需要导出图表,可以选择几个选项。
还有一个新的proc - proc mschart
- 在SAS 9.4 TS1M3中启用,将在一两个月内发布,这将生成ODS EXCEL
中的Excel图表(即,不是图像,但是告诉Excel在这里制作图表。)