SAS中文论坛

标题: 请教 [打印本页]

作者: shiyiming    时间: 2010-6-3 22:42
标题: 请教
现在有客户资料cust_id在数据集a中,客户资料中包括客户的开户时间,现在想对客户的开户时间open_date从2007年1月到2009年9月,按照月进行划分,逐个输出,不知道这样的宏程序怎么谢谢。

单个的程序是这样的

proc sql;
create table s200701 as select cust_id from from a where open_date>mdy(12,31,2006) and mdy(2,1,2007)>open_date
quit;
作者: shiyiming    时间: 2010-6-4 00:11
标题: Re: 请教
[code:2ga41rf3]data a;
        do open_date = '01jan2007'd to '01jan2009'd;
                cust_id = put(round(1000*ranuni(1), 1e2), z4.);
                output;
        end;
        format open_date date11.;
run;

%macro out(ss);
   data &ss;
                set a(where =( 's'||put(year(open_date), 4.)||put(month(open_date),z2.) = "&ss"));
%mend out;

proc sql;
        create table aa as
                select  distinct 's'||put(year(open_date), 4.)||put(month(open_date),z2.) as y
                        from a where not missing(open_date);
quit;
data _null_;
        set aa;
        call execute('%out('|| y||')');  run;
run;[/code:2ga41rf3]
程序的效率有点问题 JingJu。




欢迎光临 SAS中文论坛 (https://mysas.net/forum/) Powered by Discuz! X3.2