|
|
楼主

楼主 |
发表于 2010-5-2 12:04:17
|
只看该作者
求助在SAS9.2版macro下运行的sql命令的问题
这是我的code:
proc sql;
create table d_cash as
select
d_all.permno,
d_all.ret,
d_all.beta,
d_all.month,
d_cash.cash_holding_prev_year as cash_holding,
(d_all.ret-d_all.alpha-d_all.beta*d_all.month_mkt_ret) as ab_ret
from
d_cash left join d_all
on
d_cash.permno=d_all.permno
and
49<=i<=60
order by
permno, month;
data d_cash;
set d_cash;
if 0<cash_holding<0.20
then
sample=1;
else
if
cash_holding>=0.20
then
sample=2;
else
sample=0;
这是log里的报错:
MPRINT(CASH_STUDY): proc sql;
NOTE: Line generated by the invoked macro "CASH_STUDY".
11 's cash holding;data d_cash;set d_cash_holding;where year(date)=&year_cycle;run;proc sql;
11 ! create table d_cash
11 ! asselectd_all.permno,d_all.ret,d_all.beta,d_all.month,d_cash.cash_holding_prev_year as
-------------
79
11 ! cash_holding,
ERROR 79-322: Expecting a LIKE.
NOTE 137-205: Line generated by the invoked macro "CASH_STUDY".
11 's cash holding;data d_cash;set d_cash_holding;where year(date)=&year_cycle;run;proc sql;
11 ! create table d_cash
11 ! asselectd_all.permno,d_all.ret,d_all.beta,d_all.month,d_cash.cash_holding_prev_year as
-
22
11 ! cash_holding,
ERROR 22-322: Syntax error, expecting one of the following: (, AS, LIKE.
NOTE: Line generated by the invoked macro "CASH_STUDY".
11 's cash holding;data d_cash;set d_cash_holding;where year(date)=&year_cycle;run;proc sql;
11 ! create table d_cash
11 ! asselectd_all.permno,d_all.ret,d_all.beta,d_all.month,d_cash.cash_holding_prev_year as
-
200
11 ! cash_holding,
ERROR 200-322: The symbol is not recognized and will be ignored.
NOTE 137-205: Line generated by the invoked macro "CASH_STUDY".
11 's cash holding;data d_cash;set d_cash_holding;where year(date)=&year_cycle;run;proc sql;
11 ! create table d_cash
11 ! asselectd_all.permno,d_all.ret,d_all.beta,d_all.month,d_cash.cash_holding_prev_year as
--
22
11 ! cash_holding,
ERROR 22-322: Syntax error, expecting one of the following: ;, (, ','.
NOTE: Line generated by the invoked macro "CASH_STUDY".
11 's cash holding;data d_cash;set d_cash_holding;where year(date)=&year_cycle;run;proc sql;
11 ! create table d_cash
11 ! asselectd_all.permno,d_all.ret,d_all.beta,d_all.month,d_cash.cash_holding_prev_year as
--
76
11 ! cash_holding,
ERROR 76-322: Syntax error, statement will be ignored.
MPRINT(CASH_STUDY): create table d_cash asselectd_all.permno,,
,d_all.month,d_cash.cash_holding_prev_year as
cash_holding,(-d_all.alpha-d_all.beta*d_all.month_mkt_ret) as ab_retfromd_cash left join
d_allond_cash.permno=d_all.permnoand49<=i<=60order bypermno, month;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds
NOTE: Line generated by the invoked macro "CASH_STUDY".
12 data d_cash;set d_cash;if 0<cash_holding<0.20thensample=1;
----------
-
1
180
------------------
180
12 ! elseifcash_holding>=0.20thensample=2
MPRINT(CASH_STUDY): data d_cash;
MPRINT(CASH_STUDY): set d_cash;
MPRINT(CASH_STUDY): if 0<cash_holding<0.20thensample=1;
MPRINT(CASH_STUDY): elseifcash_holding>=0.20thensample=2;
MPRINT(CASH_STUDY): elsesample=0;
MPRINT(CASH_STUDY): retain sample;
WARNING 1-322: Assuming the symbol THEN was misspelled as thensample.
ERROR 180-322: Statement is not valid or it is used out of proper order.
貌似是分不出as select以及把
then 语句和变量sample 当成了thensample这个变量。
总之,有点长,谢谢知情人的回答。 |
|