Introduction to Data Set Options Mark Tabladillo, Ph.D. Software Developer, MarkTab Consulting Associate Faculty, University of Phoenix January 30, 2007.

Slides:



Advertisements
Similar presentations
Find It Using SAS By David Steves. Would you like to be able to search SAS programs for certain expressions? Example: I have a list of SAS programs which.
Advertisements

The INFILE Statement Reading files into SAS from an outside source: A Very Useful Tool!
I OWA S TATE U NIVERSITY Department of Animal Science PROC ROBUSTRET & Evaluating Regression analyses With The Help of PROC RSQUARE Animal Science 500.
Introduction to SAS Programming Christina L. Ughrin Statistical Software Consulting Some notes pulled from SAS Programming I: Essentials Training.
SAS Programming: Working With Variables. Data Step Manipulations New variables should be created during a Data step Existing variables should be manipulated.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
Basic And Advanced SAS Programming
Using Proc Datasets for Efficiency Originally presented as a Coder’s NESUG2000 by Ken Friedman Reviewed by Karol Katz.
Chapter 18: Modifying SAS Data Sets and Tracking Changes 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Understanding SAS Data Step Processing Alan C. Elliott stattutorials.com.
Into to SAS ®. 2 List the components of a SAS program. Open an existing SAS program and run it. Objectives.
Creating SAS® Data Sets
Welcome to SAS…Session..!. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.
“SAS macros are just text substitution!” “ARRRRGGHHH!!!”
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
SAS PROC REPORT PROC TABULATE
Chapter 9 Producing Descriptive Statistics PROC MEANS; Summarize descriptive statistics for continuous numeric variables. PROC FREQ; Summarize frequency.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.
Introduction to SAS BIO 226 – Spring Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.
Generation Why: How Generation Data Sets Can Help Lisa Eckler, Lisa Eckler Consulting.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Introduction to SAS. What is SAS? SAS originally stood for “Statistical Analysis System”. SAS is a computer software system that provides all the tools.
SAS Options – Versatile Players in the Game of SAS Denise Poll, SAS Institute Inc.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
Introduction to Using the Data Step Hash Object with Large Data Sets Richard Allen Peak Stat.
SQL Chapter Two. Overview Basic Structure Verifying Statements Specifying Columns Specifying Rows.
1 Filling in the blanks with PROC FREQ Bill Klein Ryerson University.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
Chapter 22: Using Best Practices 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Priya Ramaswami Janssen R&D US. Advantages of PROC REPORT -Very powerful -Perform lists, subsets, statistics, computations, formatting within one procedure.
Chapter 5 Reading and Manipulating SAS ® Data Sets and Creating Detailed Reports Xiaogang Su Department of Statistics University of Central Florida.
Introduction to Computer Programming
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
Chapter 4 concerns various SAS procedures (PROCs). Every PROC operates on: –the most recently created dataset –all the observations –all the appropriate.
Chapter 17: Formatting Data 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
Lesson 8 - Topics Creating SAS datasets from procedures Using ODS and data steps to make reports Using PROC RANK Programs in course notes LSB 4:11;5:3.
Controlling Input and Output
SAS for Data Management and Analysis
Computing with SAS Software A SAS program consists of SAS statements. 1. The DATA step consists of SAS statements that define your data and create a SAS.
Stored Procedures / Session 4/ 1 of 41 Session 4 Module 7: Introducing stored procedures Module 8: More about stored procedures.
Chapter 17 Supplement: Alternatives to IF-THEN/ELSE Processing STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South.
1 EPIB 698C Lecture 1 Instructor: Raul Cruz-Cano
SAS Programming Training Instructor:Greg Grandits TA: Textbooks:The Little SAS Book, 5th Edition Applied Statistics and the SAS Programming Language, 5.
HRP Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
Online Programming| Online Training| Real Time Projects | Certifications |Online Classes| Corporate Training |Jobs| CONTACT US: STANSYS SOFTWARE SOLUTIONS.
Quiz 3 Topics Functions – using and writing. Lists: –operators used with lists. –keywords used with lists. –BIF’s used with lists. –list methods. Loops.
Copyright 2009 The Little Engine That Could: Using EXCEL LIBNAME Engine Options to Enhance Data Transfers between SAS® and Microsoft® Excel Files William.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 14 & 19 By Tasha Chapman, Oregon Health Authority.
Working Efficiently with Large SAS® Datasets Vishal Jain Senior Programmer.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 16 & 17 By Tasha Chapman, Oregon Health Authority.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 5 & 6 By Ravi Mandal.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 3 & 4 By Tasha Chapman, Oregon Health Authority.
3 A Guide to MySQL.
Applied Business Forecasting and Regression Analysis
© 2016 Pearson Education, Ltd. All rights reserved.
The Selection Structure
Instructor: Raul Cruz-Cano
Tamara Arenovich Tony Panzarella
SAS Essentials How SAS Thinks
SET statement in DATA step
Quick Data Summaries in SAS
Defining and Calling a Macro
Producing Descriptive Statistics
COMPUTER PROGRAMMING SKILLS
Presentation transcript:

Introduction to Data Set Options Mark Tabladillo, Ph.D. Software Developer, MarkTab Consulting Associate Faculty, University of Phoenix January 30, 2007

Introduction Data set options allow features during dataset processing Most SAS data set options can apply to either input or output SAS data sets in DATA steps or procedure (PROC) steps Data set options allow the data step to control variables, observations, security, and data set attributes

Outline Define data set options Provide examples in four categories Discuss data set processing rules

Outline Define data set options Provide examples in four categories Discuss data set processing rules

Definition Data set options specify actions that apply only to the SAS data set with which they appear.

Syntax Specify a data set option in parentheses after a SAS data set name. To specify several data set options, separate them with spaces. (option-1=value-1 )

Outline Define data set options Provide examples in four categories Discuss data set processing rules

Quick Examples Data set options enable us to perform operations such as these: –Renaming variables –Selecting only the first or last n observations for processing –Dropping variables from processing or from the output data set –Specifying a password for a data set –Adding dataset labels

Common Option Categories Variable Control Observation Control Security Data Set Attributes

Examples Dataset data work.sales (drop=i randomState); length state $2 sales 8 randomState 3; do i = 1 to 2500; randomState = round(rand('gaussian',3,1)+0.5); if randomState in (1,2,3,4,5) then do; select(randomState); when(1) state='TN'; when(2) state='AL'; when(3) state='GA'; when(4) state='FL'; when(5) state='MS'; end; sales = int(rand('gaussian', ,500000)); output work.sales; end; run;

List of Common Options SAS Data Set OptionDescription Variable Control DROP= Data Set Option Excludes variables from processing or from output SAS data sets KEEP= Data Set Option Specifies variables for processing or for writing to output SAS data sets RENAME= Data Set Option Changes the name of a variable

Examples: Variable Control data work.salesReformat; set work.sales (drop=sales); run; data work.salesReformat2; set work.sales (keep=state); run; proc sort data=work.sales (rename=(state=salesState)) out=work.salesReformat3 (drop=sales); by salesState; run;

List of Common Options SAS Data Set OptionDescription Observation Control FIRSTOBS= Data Set Option Specifies which observation SAS processes first IN= Data Set OptionCreates a variable that indicates whether the data set contributed data to the current observation OBS= Data Set OptionSpecifies when to stop processing observations WHERE= Data Set Option Selects observations that meet the specified condition

Examples: Observation Control * (obs - firstobs) + 1 = results; data work.selectObs1; set work.sales (firstobs=1 obs=200); run; data work.selectObs2; set work.sales (firstobs=200 obs=400); run; proc print data=work.sales (obs=25); run; proc freq data=work.sales (firstobs=1); tables state; run; proc means data=work.sales (obs=max); class state; var sales; run;

Examples: Observation Control data work.combineObs1; set work.selectObs1 (in=in1) work.selectObs2 (in=in2); length source $12; if in1 then source = 'Dataset One'; else if in2 then source = 'Dataset Two'; run; data work.combineObs2; set work.selectObs1 (in=in1) work.selectObs2 (in=in2); if in1 and in2 then output; run;

List of Common Options SAS Data Set OptionDescription SecurityALTER= Data Set Option Assigns an alter password to a SAS file and enables access to a password- protected SAS file ENCRYPT= Data Set Option Encrypts SAS data files PW= Data Set Option Assigns a read, write, or alter password to a SAS file and enables access to a password-protected SAS file READ= Data Set Option Assigns a read password to a SAS file and enables access to a read-protected SAS file WRITE= Data Set Option Assigns a write password to a SAS file and enables access to a write-protected SAS file

Examples: Security data work.secure1 (alter=NoErrors); set work.sales; run; data work.secure2; set work.sales (alter=NoErrors); run; * Note: A SAS password does not control access to a SAS file beyond the SAS system. You should use the operating system-supplied utilities and file-system security controls in order to control access to SAS files outside of SAS.; data work.secure3 (encrypt=yes pw=Scramble); set work.sales; run; proc sort data=work.secure3 (pw=scramble) out=work.secure4; by state sales; run;

List of Common Options SAS Data Set OptionDescription Data Set Attributes COMPRESS= Data Set Option Controls the compression of observations in an output SAS data set GENMAX= Data Set Option Requests generations for a data set and specifies the maximum number of versions INDEX= Data Set Option Defines indexes when a SAS data set is created LABEL= Data Set Option Specifies a label for the SAS data set

Examples: Data Set Attributes data work.compress1 (compress=yes label="Attempt at Compression"); set work.sales; run; data work.masterSalesDataset (genmax=3); set work.sales; run; data work.masterSalesDataset; set work.masterSalesDataset work.selectObs1; run; data work.masterSalesDataset; set work.sales work.selectObs1; run;

Outline Define data set options Provide examples in four categories Discuss data set processing rules

Input and Output Datasets If a data set option is associated with an input data set, the action applies to the data set that is being read. If the option appears in the DATA statement or after an output data set specification in a PROC step, SAS applies the action to the output data set.

Input and Output Datasets data _null_; run; data; run; data _null_; set _null_; if _n_ ge 0 then put 'hello'; run; data _null_; if _n_ ge 0 then put 'hello'; set _null_; run;

Order of Execution When data set options appear on both input and output data sets in the same DATA or PROC step, SAS applies data set options to input data sets before it evaluates programming statements or before it applies data set options to output data sets. Likewise, data set options that are specified for the data set being created are applied after programming statements are processed.

Order of Execution data work.salesReformat4 (rename=(sales=monthlySales)); set work.sales; sales = sales/12; run; data work.salesReformat5; set work.sales (rename=(sales=monthlySales)); monthlySales = monthlySales/12; run;

Specification Conflicts In some instances, data set options conflict when they are used in the same statement. For example, you cannot specify both the DROP= and KEEP= options for the same variable in the same statement.

Statement Definition A SAS statement is a series of items that may include keywords, SAS names, special characters, and operators. All SAS statements end with a semicolon. A SAS statement either requests SAS to perform an operation or gives information to the system.

Timing Conflicts Timing can also be an issue in some cases. For example, if using KEEP= and RENAME= on a data set specified in the SET statement, KEEP= needs to use the original variable names, because SAS will process KEEP= before the data set is read. The new names specified in RENAME= will apply to the programming statements that follow the SET statement.

Timing Conflicts proc sort data=work.sales (keep=sales state rename=(sales=monthlySales)) out=work.salesReformat6; by state monthlySales; run; proc sort data=work.sales (rename=(sales=monthlySales) keep=sales state) out=work.salesReformat7; by state monthlySales; run;

Overriding System Options Many system options and data set options share the same name and have the same function. The data set option overrides the system option for the data set in the step in which it appears. System options remain in effect for all DATA and PROC steps in a SAS job or session, unless they are respecified.

Conclusion DATA set options allow features during data step processing The SAS System Documentation provides specific details on the syntax

Contact Information Mark Tabladillo MarkTab Consulting