各位老师好:
请问能否将这2个sql合并成1个?
谢谢!
或者:
同个data步中上面生成变量下面可以直接调用,
sql中是否不能直接调用?
proc sql;
create table card1 as
select *,
int(addcode/1000000) as procode,
int(rearea/1000000) as citycode,
year(dateotype) as bgyear,
input(compress(card_id,"‘’"),$40.) as cardid,
input(compress(ic,"‘’"),$18.) as ic_
from card
where areatype not in ("港澳台" "外籍") and
flagoval eq "已终审卡" and
typeocase in ("实验室诊断病例" "临床诊断病例") and
dateotype between '01jul1985'd and '30jun2014'd ;
quit;
proc sql;
create table card2 as
select *
from card1
where procode eq 44;
quit;
***上面2个sql生成的结果与data步生成的一样;
data card1;
set card;
procode=int(addcode/1000000);
citycode=int(addcode/10000); *addcode=现住址;
reptcode=int(rearea/1000000); *rearea=报告地;
cityrept=int(rearea/10000);
bgyear=year(dateotype);
cardid=input(compress(card_Id,"‘’"), $40.);
ic_=input(compress(ic,"‘’"), $18.);
if areatype='港澳台' or areatype='外籍' then delete;
if (flagoval='已终审卡' and (typeocase='实验室诊断病例' or typeocase='临床诊断病例')) and procode=44;
if '01jul1985'd<=dateotype<='30jun2014'd; *dateotype=录入日期; *有7例的录入日期是20140701;
run;