lundi 27 juillet 2015

SAS `select`...`when` based on range

I have blocks of code which need to be done if a fixed variable falls into a particular range, e.g.

IF attained_age > 84 AND attained_age < 90 then
    do;
       /* block 1*/
    end;
ELSE IF attained_age > 89 AND attained_age < 95 then
    do;
       /* block 2*/
    end;
ELSE IF attained_age > 94 then
    do;
       /* block 3*/
    end;

Is there a better way of writing this, with something like SELECT...WHEN for example? I would prefer not to list all individual values of attained age in the WHEN clauses though...

Aucun commentaire:

Enregistrer un commentaire