SlideShare a Scribd company logo
SAS Techies [email_address] http://www.sastechies.com
When you store your data in a SAS data file, you use the sum of the data storage space that is required for the following: the descriptor portion  the observations  any storage overhead  any associated indexes. Techniques: Get rid of waste space Compress datasets Use Views 11/13/09 SAS Techies  2009
LENGTH  variable(s)  $   length ;   where  variable(s)  specifies the name of one or more SAS variables, separated by spaces.  length  is an integer from 1 to 32,767 that specifies the length of the variable(s).  SAS assigns a default length of 8 bytes to the Character variable  SAS character variables store data as 1 character per byte. A SAS character variable can be from 1 to 32,767 bytes in length.  One way to reduce the amount of data storage space that you need is to reduce the length of character data, thereby eliminating wasted space. Instead of recording the complete name in the data set, you could assign a code/abbreviation. 11/13/09 SAS Techies  2009
The default length for a numeric variable is 8 bytes.  SAS stores all numeric values using double-precision floating-point representation. SAS stores the value of a numeric variable as multiple digits per byte. A SAS numeric variable can be from 2 to 8 bytes or 3 to 8 bytes in length, depending on your operating environment.  LENGTH  var length   <DEFAULT= n >;   where  the optional DEFAULT= n  argument changes the default number of bytes that SAS uses to store the values of any newly created numeric variables. If you use the DEFAULT= argument, you do not need to list any  variable(s) .  11/13/09 SAS Techies  2009
Compressing a data file is a process that reduces the number of bytes that are required in order to represent each observation in a data file.  Reading from or writing to a compressed file during data processing requires fewer I/O operations because there are fewer data set pages in a compressed data file.  However, in order to read a compressed file, each observation must be uncompressed. This requires more CPU resources than reading an uncompressed file.  Also, in some cases, compressing a file might actually increase its size rather than decreasing it. 11/13/09 SAS Techies  2009
By default, a SAS data file is not compressed. In uncompressed data files,  each data value and each observation  occupies the same number of bytes as any other data value of that variable.  character values are padded with blanks.  numeric values are padded with binary zeros.  there is a 16-byte overhead at the beginning of each page.  there is a 1-bit per observation overhead (rounded up to the nearest byte) at the end of each page; this bit denotes an observation's status as deleted or not deleted.  new observations are added at the end of the file. If a new observation won't fit on the current last page of the file, a whole new data set page is added.  the descriptor portion of the data file is stored at the end of the first page of the file.  Compressed data files  treat an observation as a single string of bytes by ignoring variable types and boundaries.  collapse consecutive repeating characters and numbers into fewer bytes.  contain a 28-byte overhead at the beginning of each page.  contain a 12-byte- or 24-byte-per-observation overhead following the page overhead. This space is used for deletion status, compressed length, pointers, and flags.  11/13/09 SAS Techies  2009
A data file is  not  a good candidate for compression if it has  few repeated characters  small physical size  few missing values  short text strings. compression can be beneficial when the data file has one or more of the following properties: It is large.  It contains many long character values.  It contains many values that have repeated characters or binary zeros.  It contains many missing values.  It contains repeated values in variables that are physically stored next to one another.  11/13/09 SAS Techies  2009
To compress a data file, you use either the COMPRESS= data set option or the COMPRESS= system option.  You use the  COMPRESS= system option  to compress all data files that you create during a SAS session.  Similarly, you use the  COMPRESS= data set option  to compress an individual data file.  CHAR  or  YES  uses the Run Length Encoding (RLE) compression algorithm, which compresses repeating consecutive bytes such as trailing blanks or repeated zeros.  BINARY  uses Ross Data Compression (RDC), which combines run-length encoding and sliding-window compression.   11/13/09 SAS Techies  2009
Another way to save disk space is to leave your data in its original location and use a SAS data view to access it. A SAS data file and a SAS data view are both types of SAS data sets. The first type, a SAS data file, contains both descriptor information about the data and the data values. The second type, a SAS data view, contains only descriptor information about the data and instructions on how to retrieve data values that are stored elsewhere.  11/13/09 SAS Techies  2009
11/13/09 SAS Techies  2009
use options and a statement to control the size and number of data buffers, which in turn can affect your programs' execution times by reducing the number of I/O operations that SAS must perform.  When you create a SAS data set using a DATA step, SAS copies the data from the input data set to a buffer in memory  one observation at a time is loaded into the program data vector  each observation is written to an output buffer when processing is complete  the contents of the output buffer are written to the disk when the buffer is full 11/13/09 SAS Techies  2009
options bufsize=30720 bufno=10;    filename orders 'c:\orders.dat';      data company.orders_fact; infile orders; <more SAS code>      run;  choosing a page/buffer size that is larger than the default can speed up execution time by reducing the number of times that SAS must read from or write to the storage medium. You can use the BUFNO= system or data set option to control the number of buffers that are available for reading or writing a SAS data set. By increasing the number of buffers, you can control how many pages of data are loaded into memory with each I/O transfer. The product of BUFNO= and BUFSIZE=, rather than the specific value of either option, determines how much data can be transferred in one I/O operation. Increasing the value of either option increases the amount of data that can be transferred in one I/O operation.  11/13/09 SAS Techies  2009
sasfile company.sales load;       proc print data=company.sales; var Customer_Age_Group;      run; proc tabulate data=company.sales;          class Customer_Age_Group;          var Customer_BirthDate;          Table Customer_Age_Group,Customer_BirthDate*(mean median);    run;       sasfile company.sales close;   Another way of improving performance is to use the SASFILE statement to hold a SAS data file in memory so that the data is available to multiple program steps. Keeping the data file open reduces open/close operations, including the allocation and freeing of memory for buffers. It is important to note that I/O processing is reduced only if there is sufficient real memory. If there is not sufficient real memory, the operating environment might  use virtual memory  use the default number of buffers.  If SAS uses virtual memory, there might be a degradation in performance.  11/13/09 SAS Techies  2009
11/13/09 SAS Techies  2009
11/13/09 SAS Techies  2009
11/13/09 SAS Techies  2009
Before you test the programming techniques, turn on the SAS system options that report resource usage. Execute the code for each programming technique in a separate SAS session. In each programming technique that you are testing, include only the SAS code that is essential for performing the task. Run your benchmarking tests under the conditions in which your final program will run. After testing is finished, consider turning off the options that report resource usage. 11/13/09 SAS Techies  2009

More Related Content

What's hot (20)

PPT
SAS Access / SAS Connect
guest2160992
 
PPT
SAS Macros
guest2160992
 
PPT
Sas Plots Graphs
guest2160992
 
PDF
Sas cheat
imaduddin91
 
PPT
SAS Proc SQL
guest2160992
 
PPTX
Proc SQL in SAS Enterprise Guide 4.3
Mark Tabladillo
 
PPTX
Understanding sas data step processing.
Ravi Mandal, MBA
 
DOCX
Base sas interview questions
Dr P Deepak
 
PPT
Arrays in SAS
guest2160992
 
PDF
A Step-By-Step Introduction to SAS Report Procedure
YesAnalytics
 
PPTX
SAS Mainframe -Program-Tips
Srinimf-Slides
 
PDF
Proc sql tips
Naresh Kumar Gamidi
 
PDF
Base SAS Full Sample Paper
Jimmy Rana
 
PPT
ABAP Programming Overview
sapdocs. info
 
PPT
Sas-training-in-mumbai
Unmesh Baile
 
PPT
Prog1 chap1 and chap 2
rowensCap
 
PDF
Hive and Shark
Amir Payberah
 
PDF
Sas ods
data-analytics
 
PDF
Sas Talk To R Users Group
georgette1200
 
DOC
Alv Grids
Michelle Crapo
 
SAS Access / SAS Connect
guest2160992
 
SAS Macros
guest2160992
 
Sas Plots Graphs
guest2160992
 
Sas cheat
imaduddin91
 
SAS Proc SQL
guest2160992
 
Proc SQL in SAS Enterprise Guide 4.3
Mark Tabladillo
 
Understanding sas data step processing.
Ravi Mandal, MBA
 
Base sas interview questions
Dr P Deepak
 
Arrays in SAS
guest2160992
 
A Step-By-Step Introduction to SAS Report Procedure
YesAnalytics
 
SAS Mainframe -Program-Tips
Srinimf-Slides
 
Proc sql tips
Naresh Kumar Gamidi
 
Base SAS Full Sample Paper
Jimmy Rana
 
ABAP Programming Overview
sapdocs. info
 
Sas-training-in-mumbai
Unmesh Baile
 
Prog1 chap1 and chap 2
rowensCap
 
Hive and Shark
Amir Payberah
 
Sas Talk To R Users Group
georgette1200
 
Alv Grids
Michelle Crapo
 

Viewers also liked (12)

PPT
Basics Of SAS Programming Language
guest2160992
 
PPTX
Presentation1
Yuxiang Zhang
 
PDF
Introduction to sas
Ajay Ohri
 
PDF
FLOW3 Experience 2012 - Keynote
Robert Lemke
 
PPTX
U23000754 data mining final project
Abhinav Singh
 
PPT
INTRODUCTION TO SAS
Bhuwanesh Rawat
 
PPSX
SAS TRAINING
Krishna Stansys
 
PPT
SAS BASICS
Bhuwanesh Rawat
 
PDF
Introduction to SAS
izahn
 
PDF
SAS Presentation
Kali Howard
 
DOCX
Sas Macro Examples
SASTechies
 
DOCX
Learn SAS Programming
SASTechies
 
Basics Of SAS Programming Language
guest2160992
 
Presentation1
Yuxiang Zhang
 
Introduction to sas
Ajay Ohri
 
FLOW3 Experience 2012 - Keynote
Robert Lemke
 
U23000754 data mining final project
Abhinav Singh
 
INTRODUCTION TO SAS
Bhuwanesh Rawat
 
SAS TRAINING
Krishna Stansys
 
SAS BASICS
Bhuwanesh Rawat
 
Introduction to SAS
izahn
 
SAS Presentation
Kali Howard
 
Sas Macro Examples
SASTechies
 
Learn SAS Programming
SASTechies
 
Ad

Similar to Improving Effeciency with Options in SAS (20)

DOCX
SAS Programming Notes
Gnana Murthy A
 
PDF
Introduction To Sas
halasti
 
PPTX
Automatic Storage Management (ASM) metrics are a goldmine: Let's use them!
BertrandDrouvot
 
PDF
DataStax | Building a Spark Streaming App with DSE File System (Rocco Varela)...
DataStax
 
DOCX
Fundamental of computer
Mousumi Biswas
 
PDF
SAS Commands
Suvojyoti Chowdhury
 
PDF
Stata tutorial university of princeton
Douglas Branco Dias Santana
 
PDF
Sas summary guide
Ashish K Sharma
 
PDF
Introduction to-sas-1211594349119006-8
thotakoti
 
PPT
Radyakin usespss
fjolla_00
 
PPTX
Apache Hadoop India Summit 2011 talk "Hadoop Map-Reduce Programming & Best Pr...
Yahoo Developer Network
 
PPT
BASE SAS Training presentation of coding
shamarites
 
DOC
Introduction to SAS
Imam Jaffer
 
PPTX
20170419 To COMPRESS or Not, to COMPRESS or ZIP
David Horvath
 
PPT
SAS Online Training by Real Time Working Professionals in USA,UK,India,Middle...
Oracle Apps R12, Financials,SCM,PA,HRMSCorporate Training
 
PPT
8323 Stats - Lesson 1 - 03 Introduction To Sas 2008
untellectualism
 
PDF
Basics of SAS
Taddesse Kassahun
 
DOC
Readme
Tooktun Love
 
PPTX
Sas
abril joseph
 
SAS Programming Notes
Gnana Murthy A
 
Introduction To Sas
halasti
 
Automatic Storage Management (ASM) metrics are a goldmine: Let's use them!
BertrandDrouvot
 
DataStax | Building a Spark Streaming App with DSE File System (Rocco Varela)...
DataStax
 
Fundamental of computer
Mousumi Biswas
 
SAS Commands
Suvojyoti Chowdhury
 
Stata tutorial university of princeton
Douglas Branco Dias Santana
 
Sas summary guide
Ashish K Sharma
 
Introduction to-sas-1211594349119006-8
thotakoti
 
Radyakin usespss
fjolla_00
 
Apache Hadoop India Summit 2011 talk "Hadoop Map-Reduce Programming & Best Pr...
Yahoo Developer Network
 
BASE SAS Training presentation of coding
shamarites
 
Introduction to SAS
Imam Jaffer
 
20170419 To COMPRESS or Not, to COMPRESS or ZIP
David Horvath
 
SAS Online Training by Real Time Working Professionals in USA,UK,India,Middle...
Oracle Apps R12, Financials,SCM,PA,HRMSCorporate Training
 
8323 Stats - Lesson 1 - 03 Introduction To Sas 2008
untellectualism
 
Basics of SAS
Taddesse Kassahun
 
Readme
Tooktun Love
 
Ad

Recently uploaded (20)

PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
July Patch Tuesday
Ivanti
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
July Patch Tuesday
Ivanti
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 

Improving Effeciency with Options in SAS

  • 1. SAS Techies [email_address] http://www.sastechies.com
  • 2. When you store your data in a SAS data file, you use the sum of the data storage space that is required for the following: the descriptor portion the observations any storage overhead any associated indexes. Techniques: Get rid of waste space Compress datasets Use Views 11/13/09 SAS Techies 2009
  • 3. LENGTH variable(s) $ length ; where variable(s) specifies the name of one or more SAS variables, separated by spaces. length is an integer from 1 to 32,767 that specifies the length of the variable(s). SAS assigns a default length of 8 bytes to the Character variable SAS character variables store data as 1 character per byte. A SAS character variable can be from 1 to 32,767 bytes in length. One way to reduce the amount of data storage space that you need is to reduce the length of character data, thereby eliminating wasted space. Instead of recording the complete name in the data set, you could assign a code/abbreviation. 11/13/09 SAS Techies 2009
  • 4. The default length for a numeric variable is 8 bytes. SAS stores all numeric values using double-precision floating-point representation. SAS stores the value of a numeric variable as multiple digits per byte. A SAS numeric variable can be from 2 to 8 bytes or 3 to 8 bytes in length, depending on your operating environment. LENGTH var length <DEFAULT= n >; where the optional DEFAULT= n argument changes the default number of bytes that SAS uses to store the values of any newly created numeric variables. If you use the DEFAULT= argument, you do not need to list any variable(s) . 11/13/09 SAS Techies 2009
  • 5. Compressing a data file is a process that reduces the number of bytes that are required in order to represent each observation in a data file. Reading from or writing to a compressed file during data processing requires fewer I/O operations because there are fewer data set pages in a compressed data file. However, in order to read a compressed file, each observation must be uncompressed. This requires more CPU resources than reading an uncompressed file. Also, in some cases, compressing a file might actually increase its size rather than decreasing it. 11/13/09 SAS Techies 2009
  • 6. By default, a SAS data file is not compressed. In uncompressed data files, each data value and each observation occupies the same number of bytes as any other data value of that variable. character values are padded with blanks. numeric values are padded with binary zeros. there is a 16-byte overhead at the beginning of each page. there is a 1-bit per observation overhead (rounded up to the nearest byte) at the end of each page; this bit denotes an observation's status as deleted or not deleted. new observations are added at the end of the file. If a new observation won't fit on the current last page of the file, a whole new data set page is added. the descriptor portion of the data file is stored at the end of the first page of the file. Compressed data files treat an observation as a single string of bytes by ignoring variable types and boundaries. collapse consecutive repeating characters and numbers into fewer bytes. contain a 28-byte overhead at the beginning of each page. contain a 12-byte- or 24-byte-per-observation overhead following the page overhead. This space is used for deletion status, compressed length, pointers, and flags. 11/13/09 SAS Techies 2009
  • 7. A data file is not a good candidate for compression if it has few repeated characters small physical size few missing values short text strings. compression can be beneficial when the data file has one or more of the following properties: It is large. It contains many long character values. It contains many values that have repeated characters or binary zeros. It contains many missing values. It contains repeated values in variables that are physically stored next to one another. 11/13/09 SAS Techies 2009
  • 8. To compress a data file, you use either the COMPRESS= data set option or the COMPRESS= system option. You use the COMPRESS= system option to compress all data files that you create during a SAS session. Similarly, you use the COMPRESS= data set option to compress an individual data file. CHAR or YES uses the Run Length Encoding (RLE) compression algorithm, which compresses repeating consecutive bytes such as trailing blanks or repeated zeros. BINARY uses Ross Data Compression (RDC), which combines run-length encoding and sliding-window compression.   11/13/09 SAS Techies 2009
  • 9. Another way to save disk space is to leave your data in its original location and use a SAS data view to access it. A SAS data file and a SAS data view are both types of SAS data sets. The first type, a SAS data file, contains both descriptor information about the data and the data values. The second type, a SAS data view, contains only descriptor information about the data and instructions on how to retrieve data values that are stored elsewhere. 11/13/09 SAS Techies 2009
  • 11. use options and a statement to control the size and number of data buffers, which in turn can affect your programs' execution times by reducing the number of I/O operations that SAS must perform. When you create a SAS data set using a DATA step, SAS copies the data from the input data set to a buffer in memory one observation at a time is loaded into the program data vector each observation is written to an output buffer when processing is complete the contents of the output buffer are written to the disk when the buffer is full 11/13/09 SAS Techies 2009
  • 12. options bufsize=30720 bufno=10;    filename orders 'c:\orders.dat';     data company.orders_fact; infile orders; <more SAS code>      run; choosing a page/buffer size that is larger than the default can speed up execution time by reducing the number of times that SAS must read from or write to the storage medium. You can use the BUFNO= system or data set option to control the number of buffers that are available for reading or writing a SAS data set. By increasing the number of buffers, you can control how many pages of data are loaded into memory with each I/O transfer. The product of BUFNO= and BUFSIZE=, rather than the specific value of either option, determines how much data can be transferred in one I/O operation. Increasing the value of either option increases the amount of data that can be transferred in one I/O operation. 11/13/09 SAS Techies 2009
  • 13. sasfile company.sales load;       proc print data=company.sales; var Customer_Age_Group;      run; proc tabulate data=company.sales;         class Customer_Age_Group;         var Customer_BirthDate;         Table Customer_Age_Group,Customer_BirthDate*(mean median);   run;      sasfile company.sales close; Another way of improving performance is to use the SASFILE statement to hold a SAS data file in memory so that the data is available to multiple program steps. Keeping the data file open reduces open/close operations, including the allocation and freeing of memory for buffers. It is important to note that I/O processing is reduced only if there is sufficient real memory. If there is not sufficient real memory, the operating environment might use virtual memory use the default number of buffers. If SAS uses virtual memory, there might be a degradation in performance. 11/13/09 SAS Techies 2009
  • 17. Before you test the programming techniques, turn on the SAS system options that report resource usage. Execute the code for each programming technique in a separate SAS session. In each programming technique that you are testing, include only the SAS code that is essential for performing the task. Run your benchmarking tests under the conditions in which your final program will run. After testing is finished, consider turning off the options that report resource usage. 11/13/09 SAS Techies 2009

Editor's Notes

  • #3: SASTechies.com Sharad C Narnindi - Attic Technologies,Inc 2005
  • #4: SASTechies.com Sharad C Narnindi - Attic Technologies,Inc 2005
  • #5: SASTechies.com Sharad C Narnindi - Attic Technologies,Inc 2005
  • #6: SASTechies.com Sharad C Narnindi - Attic Technologies,Inc 2005
  • #7: SASTechies.com Sharad C Narnindi - Attic Technologies,Inc 2005
  • #8: SASTechies.com Sharad C Narnindi - Attic Technologies,Inc 2005
  • #9: SASTechies.com Sharad C Narnindi - Attic Technologies,Inc 2005
  • #10: SASTechies.com Sharad C Narnindi - Attic Technologies,Inc 2005
  • #11: SASTechies.com Sharad C Narnindi - Attic Technologies,Inc 2005
  • #12: SASTechies.com Sharad C Narnindi - Attic Technologies,Inc 2005
  • #13: SASTechies.com Sharad C Narnindi - Attic Technologies,Inc 2005
  • #14: SASTechies.com Sharad C Narnindi - Attic Technologies,Inc 2005
  • #15: SASTechies.com Sharad C Narnindi - Attic Technologies,Inc 2005
  • #16: SASTechies.com Sharad C Narnindi - Attic Technologies,Inc 2005
  • #17: SASTechies.com Sharad C Narnindi - Attic Technologies,Inc 2005
  • #18: SASTechies.com Sharad C Narnindi - Attic Technologies,Inc 2005