【发布时间】:2021-08-22 22:43:30
【问题描述】:
data PROFILE;
input ID $ NAME $ Birthday $ Sex $ State $ Cust_Type $ Product $ Balance Last_tran_date $;
cards;
1001 John 1/1/1969 M CA Gold Checking 1000 9/1/2015
1002 Mary 2/1/2072 F CA Silver Saving 2000 10/1/2015
1003 Peter 3/1/1982 M NY Gold Loan 3000 10/3/2016
1004 Mary 4/1/1992 F NY Silver Checking 4000 9/17/2016
;
run;
data profile;
set profile;
today=DATE();
age = FLOOR((INTCK('month',birthday,today) - (day(today) < day(birthday)))/12);
year = year(last_tran_date);
drop today;
run;
******;
%let today=%sysfunc(today(),date9.);
%put &today;
%let report =Detail Listing Of Account;
%put &report;
%macro profile (title=, state=, age=, year=,);
proc report data=profile nowd colwidth=10 spacing=5 headline headskip;
column id name state age year balance;
compute before;
line @20 "title: &report" @68 "Run Date: &today ";
/* line @20 "state: &state " @45 "Age: <= &age " @68 "Last_Tran_Date: &year "; */
line @20 "state: &state " @68 "Last_Tran_Date: &year ";
endcomp;
compute after;
line 60* "_";
line @40 'total balance ='
balance.sum dollar6.;
endcomp;
run;
%mend;
%profile(title=report,state="NY",age=39, year=2016);
我需要 marco 解决方案,例如:
%profile(Title = Report, state = %str('NY', 'CA'), age = 18-40, year = 2016, Total_balance=on);
%profile(age = 39, year = 2016, Total_balance=off);
谁能帮助我打开或关闭年龄范围和总余额的宏观部分?试了很多次还是可以的 找不到完整的解决方案。非常感谢!
【问题讨论】:
-
这是否意味着您已经知道如何生成报告并且只是在寻求将代码转换为宏的帮助?如果是这样,请显示您将用于在问题中生成示例输出的代码。
-
感谢回复,我已经更新了宏代码,运行成功。唯一的事情是我不知道如何将年龄作为范围选择并打开或关闭总余额。非常感谢!
-
您实际上并未使用参数值来选择要包含在报告中的数据。您没有为要包含的变量或总余额控制添加参数。