Type : CREATION_INTERNE
Los ejemplos utilizan datos generados (datalines) o SASHELP.
| 1 | LIBNAME mylib ; |
| 2 | |
| 3 | DATA mylib.shoes; |
| 4 | SET sashelp.shoes; |
| 5 | where Sales>=500000; |
| 6 | RUN; |
| 7 | PROC PRINT DATA=mylib.shoes; |
| 8 | var Region Product Sales; |
| 9 | RUN; |
| 10 | |
| 11 | DATA mylib.shoes2; |
| 12 | SET mylib.shoes; |
| 13 | where Region="Canada"; |
| 14 | RUN; |
| 15 | |
| 16 | PROC PRINT DATA=mylib.shoes2; |
| 17 | var Region Product Sales; |
| 18 | RUN; |
| 1 | |
| 2 | DATA mylib.shoes; |
| 3 | SET mylib.shoes; |
| 4 | where Sales>=500000 and Region="Canada"; |
| 5 | keep Region Product Sales; |
| 6 | RUN; |
| 7 | |
| 8 | PROC PRINT DATA=mylib.shoes; RUN; |
| 1 | DATA class; |
| 2 | SET sashelp.class; |
| 3 | where sex="M" and age >= 15; |
| 4 | RUN; |
| 5 | PROC PRINT DATA=class; |
| 6 | RUN; |
| 1 | DATA class; |
| 2 | SET sashelp.class; |
| 3 | where sex="M" or age>=15; |
| 4 | RUN; |
| 5 | PROC PRINT DATA=class; |
| 6 | title 'OR finds all Males and Anyone 15 Years or Older'; |
| 7 | RUN; |
| 1 | DATA class; |
| 2 | SET sashelp.class; |
| 3 | where age < 15 and sex NE "M"; |
| 4 | RUN; |
| 5 | PROC PRINT DATA=class; |
| 6 | title 'Finds Females |
| 7 | Older less than 15 Years'; |
| 8 | RUN; |
| 1 | DATA class; |
| 2 | SET sashelp.class; |
| 3 | where age>15 or height<60 and sex="F"; |
| 4 | RUN; |
| 5 | PROC PRINT DATA=class; |
| 6 | title 'age > 15 OR height < 60 AND sex = F'; |
| 7 | RUN; |
| 1 | DATA class; |
| 2 | SET sashelp.class; |
| 3 | where (age>15 or height<60) and sex="F"; |
| 4 | RUN; |
| 5 | PROC PRINT DATA=class; |
| 6 | title '(age > 15 OR height < 60) AND sex = F'; |
| 7 | RUN; |
| 1 | DATA sales; |
| 2 | SET sashelp.shoes(where=(Region="Canada" and Sales<2000)); |
| 3 | RUN; |
| 4 | PROC PRINT DATA=sales; RUN; |
| 1 | /* Specify the WHERE= data set option on the output CAS |
| 2 | table (unsupported for CAS DATA step processing) */ |
| 3 | |
| 4 | DATA mylib.sales(where=(Region="Canada" and Sales<2000)); |
| 5 | SET mylib.shoes; |
| 6 | RUN; |
| 7 | PROC PRINT DATA=mylib.sales; RUN; |
| 1 | DATA mybaseball(index=(team)); |
| 2 | SET sashelp.baseball; |
| 3 | RUN; |
| 4 | |
| 5 | DATA mybaseball; |
| 6 | SET sashelp.baseball; |
| 7 | where Team="Atlanta"; |
| 8 | keep Name Team Position; |
| 9 | RUN; |
| 10 | PROC PRINT DATA=mybaseball; RUN; |