STAT 541 Chapter 19 Introduction to Efficient SAS

  • Slides: 12
Download presentation
STAT 541 Chapter 19: Introduction to Efficient SAS Programming ©Spring 2012 Imelda Go, John

STAT 541 Chapter 19: Introduction to Efficient SAS Programming ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina 1

SAS System Options to Track Resources n We have already used STIMER – CPU

SAS System Options to Track Resources n We have already used STIMER – CPU Time and Real Time n FULLSTIMER tracks additional resources (though perhaps not as many as listed here) – – I/O swaps Number of buffers Buffer size Memory 2

SAS System Options to Track Resources n My system’s output from FULLSTIMER: NOTE: PROCEDURE

SAS System Options to Track Resources n My system’s output from FULLSTIMER: NOTE: PROCEDURE SORT used (Total process time): real time 0. 04 seconds user cpu time 0. 00 seconds system cpu time 0. 00 seconds Memory 88 k OS Memory 10920 k Timestamp 4/16/2012 11: 26: 43 AM 3

SAS System Options to Track Resources n Typical considerations – – – Real time/CPU

SAS System Options to Track Resources n Typical considerations – – – Real time/CPU time Increasing buffer size/# of pages vs. Memory Decreasing I/O vs. Memory 4

Benchmarking n The chapters that follow will use benchmarking to study – – Memory

Benchmarking n The chapters that follow will use benchmarking to study – – Memory Usage Data Storage Space Best Practices Efficient Sorting 5

Benchmarking n The chapters that follow will use benchmarking to study – – Memory

Benchmarking n The chapters that follow will use benchmarking to study – – Memory Usage Data Storage Space Best Practices Efficient Sorting 6

Benchmarking n n SAS uses data sets of various sizes from SASUSER for benchmarking

Benchmarking n n SAS uses data sets of various sizes from SASUSER for benchmarking on a variety of straightforward tasks Benchmarking guidelines are detailed – Include only essential code – Replication – Realistic conditions 7

STAT 541 Chapter 20: Controlling Memory Usage ©Spring 2012 Imelda Go, John Grego, Jennifer

STAT 541 Chapter 20: Controlling Memory Usage ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina 8

Page Size and Buffers n n SAS copies data a “page” at a time

Page Size and Buffers n n SAS copies data a “page” at a time to a buffer in memory Observations are loaded into the PDV (Program Data Vector) one at a time, processed, then read to an output buffer When the output buffer is full, its contents are written to an output SAS data set. I/O is measured when input data is copied to the input buffer and when output buffer contents are written to the external data set. 9

Page Size and Buffers n n n We could reduce the number of I/O

Page Size and Buffers n n n We could reduce the number of I/O operations (or swaps) by increasing the page (or buffer) size, or by increasing the number of buffers (some systems allow only a single buffer) PROC CONTENTS can print the page size Use BUFSIZE and BUFNO options to change the page size and # of buffers – Obviously, such changes should not be made without an understanding of system defaults etc 10

Page Size and Buffers Example proc contents data=stat 541. meddb; run; data meddb; set

Page Size and Buffers Example proc contents data=stat 541. meddb; run; data meddb; set stat 541. meddb; run; data meddb (bufsize=6144 bufno=2); set stat 541. meddb; run; n 11

SASFILE n n The SASFILE statement holds the data set in memory. Useful when

SASFILE n n The SASFILE statement holds the data set in memory. Useful when – – – n The data will be used for multiple data/proc steps Sufficient real memory is available A part of the data can be processed separately Be aware of unintended consequences when not enough memory is available. 12