Les presentamos una alternativa que reemplaza al clásico 'if... then... else' dentro del Paso Data (Data Step): SELECT.
Para los que conocen el 'Proc SQL', es similar al uso de 'case'
/********************************************************************************/
/* Condicional lógico SELECT en un Paso Data (Data Step) */
/* Notar que el código queda mucho más legible, en especial cuando */
/* hay muchas condiciones */
/********************************************************************************/
/*-------------------*/
/* inicio del código */
/*-------------------*/
data movies;
input Titulo & $30. Duracion;
DATALINES;
El satánico Dr. No 110
Doctor Zhivago 197
El Grinch 85
Doctor Sleep 152
Doctor Strange 105
;
DATA SELECT_Ejemplo;
SET MOVIES;
LENGTH Movie_Longitud $ 5;
SELECT;
WHEN (Duracion < 120) Movie_Longitud = 'Corta';
WHEN (Duracion > 160) Movie_Longitud = 'Larga';
OTHERWISE Movie_Longitud = 'Media';
END;
RUN;
/*----------------*/
/* fin del código */
/*----------------*/
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.