SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 605|回复: 1
打印 上一主题 下一主题

请教

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2010-6-3 22:42:30 | 只看该作者

请教

现在有客户资料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;
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
沙发
 楼主| 发表于 2010-6-4 00:11:26 | 只看该作者

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。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2026-2-4 05:03 , Processed in 0.066110 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表