利用SAS在program中计算Term_Unit的时候,想用SQL写出来,就写出了如下的code:
proc sql;
create table term_unit_sql as
select business_section,subscription_year,subscription_number,vehicle_number,
substr(postal_code,1,1) in ("K","L","M","N","P") THEN Province="ON"
else Province="XX",
TERM_UNIT=ROUND((mdy(input(substr(expiry_date,5,2),2.),
input(substr(expiry_date,7,2),2.),
input(substr(expiry_date,1,4),4.))
-mdy(input(substr(effective_date,5,2),2.),
input(substr(effective_date,7,2),2.),
input(substr(effective_date,1,4),4.)))/365.25,.1);
quit;
试过之后Log里面总有这样的错误提示:
substr(postal_code,1,1) in ("K","L","M","N","P")
THEN Province="ON"
----
22
76
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, !, &, ',', AND, AS,
FORMAT, FROM, INFORMAT, INTO, LABEL, LEN, LENGTH, OR, TRANSCODE, |.
ERROR 76-322: Syntax error, statement will be ignored.

[cry]求解!!
如果在sql中写data step,可以吗? 或者有啥说法??
跪谢跪谢!!

[em49]