RTSUG 04Feb2014: Beyond Directory Listings in SAS By: Jim Worley.

Slides:



Advertisements
Similar presentations
Lectures on File Management
Advertisements

Getting Started: Ansoft HFSS 8.0
Introduction to SAS Programming Christina L. Ughrin Statistical Software Consulting Some notes pulled from SAS Programming I: Essentials Training.
Working Smarter, Not Harder with DDE: Did I Really Spend All That Time Just Formatting My Report? Bobby Kidd Vice President Senior Statistical Portfolio.
11 WORKING WITH GROUPS Chapter 7. Chapter 7: WORKING WITH GROUPS2 CHAPTER OVERVIEW  Understand the functions of groups and how to use them.  Understand.
Linux+ Guide to Linux Certification, Second Edition
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment Chapter 4: Implementing and Managing Group and Computer Accounts.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment Chapter 4: Implementing and Managing Group and Computer Accounts.
Guide To UNIX Using Linux Third Edition
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment Chapter 4: Implementing and Managing Group and Computer Accounts.
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
Introduction to Linux and Shell Scripting Jacob Chan.
Chapter 7 WORKING WITH GROUPS.
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.
Records and Information Management IT - Enterprise Content Management SPIDR II Global Features Reference Guide April 2013.
Biostatistics Analysis Center Center for Clinical Epidemiology and Biostatistics University of Pennsylvania School of Medicine Minimum Documentation Requirements.
Advanced Shell Programming. 2 Objectives Use techniques to ensure a script is employing the correct shell Set the default shell Configure Bash login and.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Stacking Rich Text Format (RTF) - %SRiT Duong Tran – Independent Contractor, London, UK Stacking Rich Text Format (RTF) - %SRiT Duong Tran – Independent.
Ch 21 Command Syntax Using the DIR Command with Parameters and Wildcards.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Chapter 21 Reading Hierarchical Files Reading Hierarchical Raw Data Files.
®® Microsoft Windows 7 for Power Users Tutorial 13 Using the Command-Line Environment.
Week Three CIT 354 Internet II. 2 Objectives Displaying Dynamic Content Sending Using Your File System Common Programming Errors Summary Quiz,
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga.
Duty Log and Chat Setup SSG Frese, Jerome S. Sensor Manager Cell 12 MDD.
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
1 Back Up with Each Submit One approach for keeping a dynamic back up copy of your current work.
EPIB 698C Lecture 2 Notes Instructor: Raul Cruz 2/14/11 1.
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)
Microsoft Office Outlook 2013 Microsoft Office Outlook 2013 Courseware # 3252 Lesson 6: Organizing Information.
Getting Started Additional information. Important DOS Commands Getting Started dirlists disk directories verdisplays OS version clsclear command prompt.
Ant & Jar Ant – Java-based build tool Jar – pkzip archive, that contains metadata (a manifest file) that the JRE understands.
1 PL\SQL Dev Templates. 2 TEMPLATE DEFINITION Whenever you create a new program unit, its initial contents are based upon a template which contains pre-defined.
5 1 Data Files CGI/Perl Programming By Diane Zak.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment Chapter 4: Implementing and Managing Group and Computer Accounts.
Searching and Sorting. Why Use Data Files? There are many cases where the input to the program may come from a data file.Using data files in your programs.
Ch 91 Pipes, Filters and Redirection. Ch 92 Overview Will use redirection to redirect standard input and standard output.
1 EndNote X2 Your Bibliographic Management Tool 29 September 2009 Humanities and Social Sciences Resource Teams.
Managing Your Inbox. Flagging Messages Message requires a specific response or action from the recipient Flagging draws attention to your request Quick.
16. Python Files I/O Printing to the Screen: The simplest way to produce output is using the print statement where you can pass zero or more expressions,
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Agenda Positional Parameters / Continued... Command Substitution Bourne Shell / Bash Shell / Korn Shell Mathematical Expressions Bourne Shell / Bash Shell.
CSCI 330 UNIX and Network Programming Unit III Shell, Part 1.
Chapter 18 Reading Free-Format Data. 2 Objectives Read free-format data not recognized in fixed fields. Read free-format data separated by non-blank delimiters,
Agenda The Linux File System (chapter 4 in text) Setting Access Permissions Directory vs File Permissions chmod Utility Symbolic Method Absolute Method.
 Simple UNIX commands  I/O techniques in C++  Solutions to Lab#0 problems  Solutions to Lab#1 problems 1.
Lesson 2 Topic - Reading in data Programs 1 and 2 in course notes –Chapter 2 (Little SAS Book)
DAY 14: ACCESS CHAPTER 1 RAHUL KAVI October 8,
Agenda The Bourne Shell – Part I Redirection ( >, >>,
Chapter 14: Combining Data Vertically 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
E | W | E | W | NHS e-Referral Service Referring Roles Issued: 27 th.
Working Efficiently with Large SAS® Datasets Vishal Jain Senior Programmer.
Hints and Tips SAUSAG Q SORTING – NOUNIQUEKEY The NOUNIQUEKEY option on PROC SORT is a useful way in 9.3 to easily retain only those records with.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 3 & 4 By Tasha Chapman, Oregon Health Authority.
Lesson 5-Exploring Utilities
Archiving and Document Transfer Utilities
Data Validation and Protecting Workbook
Chapter 2: Getting Data into SAS
Shell Script Assignment 1.
SAS Programming Introduction to SAS.
Data File Import / Export
Command Syntax Chapter 2 Using the DIR Command with
Make Your Code File Driven Methods to let SAS collect file names in your system Lu Zhang Beijing, China 1.
Automating SAS through the Power of VB Script
Implementing and Managing Group and Computer Accounts
SPL – PS1 Introduction to C++.
Presentation transcript:

RTSUG 04Feb2014: Beyond Directory Listings in SAS By: Jim Worley

Directory Listings in SAS – What is missing? –There are multiple ways in SAS to get a list of directory contents, including using SAS file functions (e.g. FILENAME, DOPEN, DNUM, etc.) –No additional information available, limits what can be done with automation –Very specific information given, no ability to customize what data is received (e.g. last modified date vs. creation date) RTSUG 04Feb2014: Beyond Directory Listings in SAS2

Using a Pipe in SAS –A “pipe” allows you to take the output messages from a system command and redirect it to another location other than the command window –In SAS, using PIPE on a FILENAME statement allows you to redirect messages from a command into a SAS dataset through the infile statement –Syntax: Filename DIRLIST pipe 'dir "C:\Users\jlw34091\examples" '; RTSUG 04Feb2014: Beyond Directory Listings in SAS3 Standard FILENAME statement Add the word PIPE after the filename handle Use a system command surrounded by single quotes –Since the system command requires being surrounded by single quotes, adding macro variables to automate command is possible but not straight forward. It is beyond the scope of this presentation but more information can be found online

The “DIR” command –Windows based command to get information about files in a directory –Has multiple flags to change what information is presented, run either “dir /?” on a command line or search Google –Some flags include “/a-d” to exclude subdirectory names, “/b” to exclude details except filename, and “/s” to search subdirectories –By default lists the modified date, file size, and file name RTSUG 04Feb2014: Beyond Directory Listings in SAS4

Raw Input Dump RTSUG 04Feb2014: Beyond Directory Listings in SAS5 filename DIRLIST pipe 'dir "C:\Users\jlw34091\examples" '; data dirlist ; length buffer $256 ; infile dirlist length=reclen dlm="~" missover; input buffer $; run ;

Only Keep Rows We Want –Adding an IF statement allows us to only keep rows meeting the criteria we want. This example will only keep SAS files. –The IF statement below does three things. First it only keeps rows that begin with a valid date. Next it deletes any rows that are a directory. Finally it only keep rows that end with “.SAS”. While the last criteria would be enough to filter out the rows we want, all three are included to show examples of different ways to filter the data. RTSUG 04Feb2014: Beyond Directory Listings in SAS6 data dirlist ; length buffer $256 ; infile dirlist length=reclen dlm="~" missover; input buffer $; if input(scan(buffer,1," "),??MMDDYY10.) and index(buffer," ") = 0 and index(upcase(buffer),".SAS") > 0; run ;

Creating Useful Variables RTSUG 04Feb2014: Beyond Directory Listings in SAS7 data dirlist ;... buffer = compbl(buffer); *Remove extra spaces; LastModDate = input(scan(buffer,1," "),MMDDYY10.); LastModTime = input(substr(buffer,12,8),Time.); FileSizeInBytes = input(scan(buffer,4," "),comma20.); FileName = substr(buffer,index(buffer,scan(buffer,5," "))); format LastModDate date9. LastModTime Time5.; run ;

Beyond the Basics –Almost any system command for Windows and UNIX/Linux can utilize the PIPE feature of the SAS filename statement –Similar to running an X command but with more feedback than just the exit status –Can be used to help automate processes based on system information without the need of any manual intervention –Some example Windows commands that can be used are: FC (for comparing two files), FIND (Search within a file), OPENFILES (to check for file locks), and WHERE (search for a file) RTSUG 04Feb2014: Beyond Directory Listings in SAS8

Contact : Jim Worley Principal Programmer/Analyst RTSUG 04Feb2014: Beyond Directory Listings in SAS9 Questions? (Time Permitting)