proc sql 是以quit结束,而非run
1 proc print data=mysas.mmsone (obs=10);
2 run;
3 proc sql;
4 title 'this is an example of proc sql';
5 select sum(wangnei) as a,date
6 from mysas.mmsone
7 where date<200904
8 group by date
9 having date in(200901,200902)
10 order by a desc;
11 quit;
注意having的用法。
稍微改进一下,可以只显示部分结果。
1 proc sql outobs=5;
2 title 'this is an example of sql and outobs';
3 select wangnei,date
4 from mysas.mmsone
5 where date<200905
6 order by wangnei desc;
7 quit;
8 proc sql;
9 describe table mysas.mmsone;
10 quit;
注意 describe table 和proc contents 功能类似。
1 proc sql outobs=5;
2 title 'this is an example of sql and outobs';
3 select wangnei,date,'test','测试'
4 from mysas.mmsone
5 where date<200905
6 order by wangnei desc;
7 quit;
在sql查询中可以直接加入文本在每一行中,测试显示,sas9.2 英文环境下不支持中文。