Using Proc Datasets for Efficiency Originally presented as a Coder’s NESUG2000 by Ken Friedman Reviewed by Karol Katz.

Slides:



Advertisements
Similar presentations
Managing Your SAS Output with the Document Procedure PhilaSUG Meeting March 15, 2011.
Advertisements

How SAS implements structured programming constructs
Axio Research E-Compare A Tool for Data Review Bill Coar.
Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
SAS Programming:File Merging and Manipulation. Reading External Files (review) data barf; * create the dataset BARF; infile ’s:\mysas\Table7.1'; * open.
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Introduction to SAS Programming Christina L. Ughrin Statistical Software Consulting Some notes pulled from SAS Programming I: Essentials Training.
Statistics in Science  Introducing SAS ® software Acknowlegements to David Williams Caroline Brophy.
Creating and Managing Views Using PROC SQL Chapter 7 1.
Basic And Advanced SAS Programming
1 Intro to the AS/400 Chapter 8 - Data File Utility Copyright 1999 by Janson Industries.
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.
IE 212: Computational Methods for Industrial Engineering
Sed sed is a program used for editing data. It stands for stream editor. Unlike ed, sed cannot be used interactively. However, its commands are similar.
Introduction to SAS. What is SAS? SAS originally stood for “Statistical Analysis System”. SAS is a computer software system that provides all the tools.
©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.
Bridging (Closing) the “bitness gap” in Sas 9.4 Ron Dewar Dalhousie U. and Cancer Care NS.
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
1 Back Up with Each Submit One approach for keeping a dynamic back up copy of your current work.
Bringing Data into SAS From Menu: –File –Import Data –Spreadsheet example first Pick file by browsing Select Library and Member (we will talk about this.
(Stream Editor) By: Ross Mills.  Sed is an acronym for stream editor  Instead of altering the original file, sed is used to scan the input file line.
I OWA S TATE U NIVERSITY Department of Animal Science Getting Your Data Into SAS (Chapter 2 in the Little SAS Book) Animal Science 500 Lecture No. 3 September.
Lesson 2 Topic - Reading in data Chapter 2 (Little SAS Book)
Introduction to SAS Essentials Mastering SAS for Data Analytics
Introduction to Using the Data Step Hash Object with Large Data Sets Richard Allen Peak Stat.
Chapter 13: sed Say what?. In this chapter … Basics Programs Addresses Instructions Control Spaces Examples.
June 12, 2009 Toronto Area SAS Society 1 What’s new in BASE SAS 9.2 Checkpoint/Restart Rupinder Dhillon Dhillon Consulting Inc.
Summer SAS Workshop Lecture 2. Summer Summer SAS Workshop Lecture 2 I’ve got Data…how do I get started? Libname Review How do you do arithmetic.
1 EPIB 698E Lecture 1 Notes Instructor: Raul Cruz 7/9/13.
1 Data Manipulation (with SQL) HRP223 – 2010 October 13, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Lesson 6 - Topics Reading SAS datasets Subsetting SAS datasets Merging SAS datasets.
How to start using SAS Tina Tian. The topics An overview of the SAS system Reading raw data/ create SAS data set Combining SAS data sets & Match merging.
Chapter 22: Using Best Practices 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Chapter 5 Reading and Manipulating SAS ® Data Sets and Creating Detailed Reports Xiaogang Su Department of Statistics University of Central Florida.
© OCS Biometric Support 1 APPEND, EXECUTE and MACRO Jim Groeneveld, OCS Biometric Support, ‘s Hertogenbosch, Netherlands. PhUSE 2010 – CC05 PhUSE 2010.
Chapter 17: Formatting Data 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS Essentials - Elliott & Woodward1.
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
1 Statistical Software Programming. STAT 6360 –Statistical Software Programming Modifying and Combining Datasets For most tasks we need to work with multiple.
Controlling Input and Output
SAS for Data Management and Analysis
An Introduction Katherine Nicholas & Liqiong Fan.
Copyright © 2004, SAS Institute Inc. All rights reserved. SASHELP Datasets A real life example Barb Crowther SAS Consultant October 22, 2004.
Lesson 2 Topic - Reading in data Programs 1 and 2 in course notes –Chapter 2 (Little SAS Book)
1 Data Manipulation (with SQL) HRP223 – 2009 October 12, 2009 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Chapter 6: Modifying and Combining Data Sets  The SET statement is a powerful statement in the DATA step DATA newdatasetname; SET olddatasetname;.. run;
Chapter 14: Combining Data Vertically 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
PROC CATALOG The Wish Book SAS® Procedure. 2 PROC CATALOG, the Wish Book SAS® Procedure Louise S. Hadden Abt Associates Inc. PROC CATALOG, the Wish Book.
1 EPIB 698C Lecture 1 Instructor: Raul Cruz-Cano
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
SAS Certification Prep Guide Chapter 7 Creating and Applying User-Defined Formats.
Copyright 2009 The Little Engine That Could: Using EXCEL LIBNAME Engine Options to Enhance Data Transfers between SAS® and Microsoft® Excel Files William.
Working Efficiently with Large SAS® Datasets Vishal Jain Senior Programmer.
Better Metadata Through SAS® II: %SYSFUNC, PROC DATASETS, and Dictionary Tables.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 5 & 6 By Ravi Mandal.
Chapter 6: Modifying and Combining Data Sets
XINFO – Scanner z/OS – JCL
SAS Programming Introduction to SAS.
Chapter 18: Modifying SAS Data Sets and Tracking Changes
Instructor: Raul Cruz-Cano
SAS Essentials How SAS Thinks
Creating the Example Data
SAS Libname Quiz (You have 5 mins to complete, fill in the blanks)
PDX SUG 2010.
Data Manipulation (with SQL)
Hans Baumgartner Penn State University
Presentation transcript:

Using Proc Datasets for Efficiency Originally presented as a Coder’s NESUG2000 by Ken Friedman Reviewed by Karol Katz

Proc Datasets, an Overview  Used to manage SAS Datasets  List,change, append and repair datasets  Create and maintain indexes  Proc DATASETS includes all capabilities of the APPEND, CONTENTS and COPY procedures  Procedure commands execute with a RUN command or another DATASETS command  The procedure remains active until another procedure, dataset statement, or QUIT command is executed

LIBNAME input ‘SAS-data-library’ ; PROC DATASETS LIBRARY = input ; DATASETS commands RUN;  APPEND vs SET  SET command reads ALL observations from the datasets being concatenated.  The APPEND command ONLY reads the observations from the dataset being appended.  If the two datasets do not contain the same variable names, types or lengths, you can use the FORCE option to force the append to take place.

APPEND vs. SET PROC DATASETS; APPEND OUT = membr_b DATA = Membr_a (WHERE = (year=2004)); QUIT; RUN; DATA membr_b; SET membr_b membr_a (WHERE = (year=2004)); RUN;

CHANGE Command  Used to rename one or more members within a SAS library  Specify old name on left of the equals sign and new name on right  The following example renames two temporary datasets PROC DATASETS ; CHANGE temp1 = Jan_Mar04 temp2 = Apr_Jun04; RUN;

Copy command  To copy or move a SAS a member from one library to another  To limit copying to specific members use either SELECT or EXCLUDE options  To move a member from one library to another and then delete the original member, use the MOVE option LIBNAME lib1 ‘SAS-data-library1’; LIBNAME lib2 ‘SAS-data-library2’; PROC DATASETS; COPY in = lib1 out = lib2 MOVE; SELECT member1 member2; * / memtype = (data); RUN;

Modify Command  Works only on one dataset at a time  Allows you to change or specify formats, informats, and labels, rename variables and create and delete indexes  For an existing dataset the MODIFY command is the best way to make changes because no observations are read in or written out during processing  Using a data step with a set statement you can also make changes, however all oberservations are read in & written out. In a large dataset time and storage can be significant

MODIFY Example: LIBNAME input ‘SAS-data-library’ ; PROC DATASETS LIBRARY = input ; MODIFY income(LABEL=‘Household Income’); RENAME oldvar=newvar; LABEL newvar=‘originally called old’; FORMAT income comma11.2; RUN; DATASETS procedure is interactive  Commands execute immediately in the order they appear  Be cautious when working with this procedure