d****i 发帖数: 121 | 1 我有个dataset,大致如下:
name time trade
AAA 9:00:00 xx
AAA 13:00:00 xx
AAA 15:20:30 xx
BBB 8:20:30 xx
BBB 12:30:00 xx
... ... ...
要求用macro计算各个公司上下午的trade frequency,以及上下午的trade frequency
different。
我把公司的名字已经从上面提取出来放在firms这个file里面了,上面的dataset我也标
记了timeflag,上午0,下午1;
下面是我的程序:
data allfirm;
set test3;
if time<"12:00:00" then timeflag=0;
if time>="12:00:00" then timeflag=1;
run;
%let firms=&firm |
a********a 发帖数: 346 | 2 %let firms=&firms?
You have not defined firms here. So &firms can not be resolved.
It should be written like
%let firms=mitbbs (whatever name you want to give) |
y****g 发帖数: 285 | 3 I do not think you need a macro for this,
why not just use
proc freq
tables
or
proc summary ... ;
...
class firmname timeflag;
output out= ...;
To get results automatically from SAS, you can seperate the output table by
timeflag, then join the two tables by firmname and calculate the difference.
Then export the final table as a csv file or txt file
or you can do these steps in Excel |