/****************************************************************************** * Programme : Read Less, Run Faster: Optimizing SAS Performance with KEEP, WHERE, and OBS * Reference : EXAMPL8F89 * Source : https://www.wearecas.eu/en/sampleCode/EXAMPL8F89 ******************************************************************************/ /* --- BLOC 1 --- */ libname mysas "c:\Users\demo"; data cars; set sashelp.cars; keep make mpg MSRP; Mpg=(MPG_City*.45)+(MPG_Highway*.55)/2; run; proc print data=cars(obs=10); run; /* --- BLOC 2 --- */ data class; set sashelp.class; where age>12 and height>=67; run; proc print data=class; run; /* --- BLOC 3 --- */ data quakes; set sashelp.quakes(where=(Magnitude>6.0)); keep Depth Type Magnitude; run; proc print data=quakes; run; data quakes2; set quakes(firstobs=5); run; proc print data=quakes2; run; /* --- BLOC 4 --- */ data quakes; set sashelp.quakes(where=(Magnitude>6.0)); keep Depth Type Magnitude; run; proc print data=quakes; run; data quakes2; set quakes(firstobs=2 obs=4); run; proc print data=quakes2; run; /* --- BLOC 5 --- */ proc print data=sashelp.comet(obs=5); title "Sashelp.Comet Data Set"; run; data comet; num=3; set sashelp.comet point=num; call symput('num',num); output; stop; run; proc print data=comet; title "Row &num from Sashelp.Comet Data Set"; run;