SAS为每个数字范围分配值

SAS assign value to each range of numbers

我已经按地区计算了鲨鱼袭击的次数,我想知道如何根据鲨鱼袭击的次数为每个地区分配救生员的数量。我用过

PROC SQL; 
SELECT Area, COUNT(*) AS N FROM work.FINAL GROUP BY AREA;

我想按以下方式分配救生员:

5 attacks = 1 lifeguard
10 attacks = 2 lifeguards
15 attacks = 3 lifeguards
20+ attacks = 4 lifeguards

我该怎么做,有什么方法可以用图表表示吗? 提前致谢!

试试这个:

PROC SQL; 
SELECT Area, COUNT(*) AS attacks  
, case 
    when calculated attacks lt 5 then 0
    when calculated attacks lt 10 then 1
    when calculated attacks lt 15 then 2
    when calculated attacks lt 20 then 3
    else 4
  end as lifeguards
FROM work.FINAL GROUP BY AREA;