chapter 19: introduction to efficient sas programming 1 stat 541 ©spring 2012 imelda go, john...

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

Upload: david-hensley

Post on 19-Jan-2016

214 views

Category:

Documents


2 download

TRANSCRIPT

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

Chapter 19: Introduction to Efficient SAS Programming

1

STAT 541

©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina

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

2

SAS System Options to Track Resources

We have already used STIMER– CPU Time and Real Time

FULLSTIMER tracks additional resources (though perhaps not as many as listed here)

– I/O swaps– Number of buffers– Buffer size– Memory

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

3

SAS System Options to Track Resources

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                            88k      OS Memory                         10920k      Timestamp            4/16/2012  11:26:43 AM

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

4

SAS System Options to Track Resources

Typical considerations– Real time/CPU time– Increasing buffer size/# of pages vs. Memory– Decreasing I/O vs. Memory

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

5

Benchmarking The chapters that follow will use

benchmarking to study– Memory Usage– Data Storage Space– Best Practices– Efficient Sorting

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

6

Benchmarking The chapters that follow will use

benchmarking to study– Memory Usage– Data Storage Space– Best Practices– Efficient Sorting

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

7

Benchmarking 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

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

Chapter 20: Controlling

Memory Usage

8

STAT 541

©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina

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

9

Page Size and Buffers 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.

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

10

Page Size and Buffers 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

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

11

Page Size and Buffers Exampleproc contents data=stat541.meddb;run;data meddb;set stat541.meddb;run;data meddb (bufsize=6144 bufno=2);set stat541.meddb;run;

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

12

SASFILE The SASFILE statement holds the data

set in memory. Useful when

– 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.