Make Your Code File Driven Methods to let SAS collect file names in your system Lu Zhang Beijing, China 1.

Slides:



Advertisements
Similar presentations
PhUSE 2010 Unit Testing and Code Coverage Assessment with SASUnit - Key Technologies for Development of reliable SAS Macros - HMS Analytical Software.
Advertisements

Operating System.
The INFILE Statement Reading files into SAS from an outside source: A Very Useful Tool!
Axio Research Idea to Application via SAS Macro Language Reading Directories Bill Coar
Guide To UNIX Using Linux Third Edition
Benefits of Automated CAD QA Brian Watt – Tribal Technology (UK)
Chapter 3 Interactivity and Expressions CSC 125 Introduction to C++ programming.
Biostatistics Analysis Center Center for Clinical Epidemiology and Biostatistics University of Pennsylvania School of Medicine Minimum Documentation Requirements.
Stacking Rich Text Format (RTF) - %SRiT Duong Tran – Independent Contractor, London, UK Stacking Rich Text Format (RTF) - %SRiT Duong Tran – Independent.
RTSUG 04Feb2014: Beyond Directory Listings in SAS By: Jim Worley.
®® Microsoft Windows 7 for Power Users Tutorial 13 Using the Command-Line Environment.
An Adaptive Version-Controlled File System Makoto Matsushita, Tetsuo Yamamoto and Katsuro Inoue Osaka University, JAPAN.
Introduction to SAS. What is SAS? SAS originally stood for “Statistical Analysis System”. SAS is a computer software system that provides all the tools.
Report Management Using the ODS DOCUMENT Destination and Report Metadata Brit Harvey February 2010.
Matlab Programming for Engineers Dr. Nidal Farhat Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
1 Back Up with Each Submit One approach for keeping a dynamic back up copy of your current work.
Data Management Console Synonym Editor
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
1 Unknown Knowns: Database Construction from Unknown Files and Variables William Klein.
SIR and the WEB By Dave Doulton University of Southampton.
Chapter 6 Review: User Defined Functions Introduction to MATLAB 7 Engineering 161.
5 1 Data Files CGI/Perl Programming By Diane Zak.
1 How to Quickly Customize your PC SAS Session PhilaSUG GSK October 27, 2004 Mary Anne Rutkowski Kathy Harkins Senior Statistical Programming Analysts.
Dissecting the Windows CE Build Process James Y. Wilson Principal Engineer, Windows Embedded MVP CalAmp, Inc. James Y. Wilson Principal Engineer, Windows.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
A brief introduction to javadoc and doxygen. What’s in a program file? 1. Comments 2. Code.
Week Two Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
I/O Software CS 537 – Introduction to Operating Systems.
SAS ® Global Forum 2014 March Washington, DC.
Solvency II Tripartite template V2 and V3 Presentation of the conversion tools proposed by FundsXML France.
NCI CBIIT LIMS ISIG Meeting– July 2007 NCI CBIIT LIMS Consortium Interface SIG Mission: focus on an overall goal of providing a library of interfaces/adapters.
Papeete, French Polynesia
Excel Translator™ Ultimate Risk Solutions, Inc.:
Node.js Modules Header Mastering Node.js, Part 2 Eric W. Greene
Managing, Storing, and Executing DTS Packages
UK Dynamo User Group South Venue 26/07/2017.
Sorting in COBOL M. M. Pickard.
INF230 Basics in C# Programming
Data Virtualization Tutorial: Introduction to SQL Script
Computer Fundamentals 1
Java Course Review.
Data Virtualization Demoette… Data Lineage Reporting
System Design.
Chapter 2: Getting Data into SAS
The Linux Operating System
Product Retrieval Statistics Canada / Statistique Canada Title page
Agenda Control Flow Statements Purpose test statement
MAKE SDTM EASIER START WITH CDASH !
What is Bash Shell Scripting?
Introduction to javadoc
3 Macro Storage.
Using Algorithms Copyright © 2008 by Helene G. Kershner.
Chapter 3 Introduction to Classes, Objects Methods and Strings
Topics Introduction to File Input and Output
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment Chapter 4: Implementing and Managing Group and Computer Accounts.
Introduction to DATA Step Programming: SAS Basics II
Chapter One: An Introduction to Programming and Visual Basic
An Introduction to Software Architecture
Cmdlets “Command-lets”
Tonga Institute of Higher Education
PhUSE 2010 Section: Coding Solutions: Paper CS01   SAS® Drug Development Program Portability Ben Bocchicchio, SAS Institute, Cary NC, US James McDermott,
Automate Repetitive Programming Tasks: Effective SAS® Code Generators
Introduction to javadoc
Implementing and Managing Group and Computer Accounts
Topics Introduction to File Input and Output
Automate & Zip files Using MACRO
Writing Robust SAS Macros
Framework Anil
Presentation transcript:

Make Your Code File Driven Methods to let SAS collect file names in your system Lu Zhang Beijing, China 1

Introduction Background SAS Data-Driven Features Most of the SAS powerful functions are based on a data-driven approach. Increased general usability as a result of independence from raw data. Dynamic output from different data contents. Fewer parameters. 2

Introduction Background Idea Needs Illumination Data-Driven feature is self proved to be an excellent approach. To extend it - Let the driven approaches not only based on the data structure but also on the external files. File driven there it is. Let SAS communicate with our operating system. 3

Introduction Background How This Idea Serves in Pharmaceutical Industry To import external data. To combine output files. Make our macros more flexible. Example (SDTM implementation with raw data being external *.csv files) %mimport(ae.csv); %mimoort(cm.csv); VS %mimport("folder path"); %mimport(mh.csv); ... No need to type their names one by one, just tell SAS where they are. 4

Introduction Aim of this paper Two Methods to implement the file driven approach SAS 'D-' functions. Using a series of SAS functions including DOPEN, DNUM and DREAD. Unnamed SAS Pipes SAS Pipes allows us using DOS commands in Windows system outside SAS. 5

Method 1: SAS 'D-' Functions Descriptions of Functions How These 'D-' Functions Works DOPEN to open a directory and return a directory identifier value. DNUM to get the numbers of members in the opened directory. DREAD to return the names of each members. DCLOSE to close the opened directory to release the thread. 6

Method 1: SAS 'D-' Functions Utilizations of Functions Utilization of These Functions and Implementation SAS Code All should be within a data step. Open a specific path under which our target files are located with DOPEN. Get the total number of files exist under the path with DNUM. In a do-loop, get each files' filename with DREAD and assign them to a variable. 7

Method 1: SAS 'D-' Functions Results of Method 1 Result Source folder Result data 8

Method 1: SAS 'D-' Functions Utilization Example (SDTM implementation with raw data being external *.csv files) %macro mimport(path=); **Code for collecting file names; …; %do i=1 %to &k; **Original code for importing files; %end; %mend;

Method 2: Unnamed SAS Pipes Basic Introduction Basic Introduction of Pipes and Dos Commands Implementing dos commands within SAS like X statement. More than X statement, SAS pipes are dynamic connections. With following SAS code we can look up for dos commands Example (SAS code to look up for dos commands) filename indata pipe 'help'; data help; infile indata truncover; input help $300.; if _n_ ne 1; run; 10

Method 2: Unnamed SAS Pipes Utilization of SAS Pipes to Read File Names Implementation SAS Code Example filename indata pipe 'dir "c:\external data\*.csv" /b'; data flst; format fname $30.; infile indata truncover; input fname; call symput("n_file",_n_); run; filename indata clear; 11

Method 2: Unnamed SAS Pipes Results With Same Case Result By Using SAS Pipes Exactly same, but less heavy code and simpler logic compared with using 'D-' functions. 12

Method 2: Unnamed SAS Pipes Further Extended UNC Path UNC - Universal Naming Convention. Many companies have their global SAS working environment in which network shares often being used. UNC path is necessary to connect to network share. It could be the chance that 'dir' may failed to find UNC path. 13

Method 2: Unnamed SAS Pipes Pipes Under UNC Path How to deal with the situation that dir failed? Dos command "subst" - Associates a path with a driver letter. Steps to establish a virtual driver that dir can find. Set SAS options 'noxwait'. Using X statement and the dos command "subst" to assign the target path to a virtual driver. With virtual driver set up, pipes could work again. 14

Method 2: Unnamed SAS Pipes Pipes Under UNC Path Example (assign a UNC path "\\global\project\data" to virtual driver) option noxwait; X 'subst n: \\global\project\data'; Example (results) 15

Discussion & Conclusion Applying in More Fields Example: To compare the latest 2 batches of extracted data. filename indata pipe 'dir “C:\extracted" /b'; data fnam; infile indata truncover; input fnam $200.; fnam2=lag(fnam); call symput('last', strip(fnam2)); call symput('current', strip(fnam)); run; File driven approaches can be more flexible.

Discussion & Conclusion Now we could: Importing external data. (CSV XLS ...) Combining outputs. (RTF LST ... ) Coordinating with other techniques to function more. With methods of: SAS 'D-' functions. SAS pipes. In addition, with SAS pipes, we gain More efficiency. Less heavy code. More flexibility. 17

Q&A Thanks 18