【sas sql proc】case end

在sql中增加case可以增加数据处理的灵活性,注意结尾的end

 1 proc sql outobs=10;
 2     title 'this is an example of sql and case';
 3     select wangnei,date,
 4             case
 5             when 200901<=date<=200903 then 'first'
 6             when 200904<=date<=200906 then 'second'
 7             else 'else'
 8             end as season
 9     from mysas.mmsone
10     where date<=200912;
11 quit;

 ---------sas 9.3 sql procedure user's guide page 35 or (49/418)

 在where字句后还可以加上许多operator

any all between-and contains exists in isnull is missing like =* 

in

 1 proc contents data=mysas.ifthen; 
 2 run;
 3 proc print data=mysas.ifthen (firstobs=1 obs=10);
 4 run;
 5 proc sql outobs=10;
 6     title 'this is a instance of in';
 7     select * from mysas.ifthen
 8     where date in(200901,200902)
 9     order by shen descending;
10 quit;

between and

1 proc sql outobs=10;
2     title 'this is a try of between and';
3     select * from mysas.ifthen
4     where date between 200905 and 201001
5     order by shen dscending;
6 quit;

like

1 proc sql outobs=50;
2     select * from &dataset
3     where  subporduct_code like 'z%' or subporduct_code like 'XX____';
4 quit;

 在where筛选条件中对于排序文本也可以用大于小于的逻辑来判断:eqt gtt ltt get let net.

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值