1 Back Up with Each Submit One approach for keeping a dynamic back up copy of your current work.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Using Macros and Visual Basic for Applications (VBA) with Excel
Tutorial 8: Developing an Excel Application
1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.
1 Chapter 12 Working With Access 2000 on the Internet.
Object-Oriented Application Development Using VB.NET 1 Chapter 13 Introduction to Data Access Classes and Persistence.
A Guide to SQL, Seventh Edition. Objectives Embed SQL commands in PL/SQL programs Retrieve single rows using embedded SQL Update a table using embedded.
A Visual Introduction to PC SAS. Start SAS by double-clicking on the SAS icon...
Copyright © 2006, SAS Institute Inc. All rights reserved. Shortcuts- what you may not know that can save you time! Elizabeth Ceranowski SAS Student Programs.
A Feature-Based of IT Automation using kaseya’s agent procedure called the wiping of unallocated disk space using cipher.exe Developed By: Estuardo Fernandez.
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.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment, Enhanced Chapter 12: Managing and Implementing Backups and Disaster Recovery.
Exploring Microsoft Excel 2002 Chapter 8 Chapter 8 Automating Repetitive Tasks: Macros and Visual Basic for Applications By Robert T. Grauer Maryann Barber.
Ch 101 Introduction to Batch Files. Ch 102 Overview Will learn to create batch files to automate a sequence of commands to accomplish various tasks.
Copyright © 2006, SAS Institute Inc. All rights reserved. Enterprise Guide 4.2 : A Primer SHRUG : Spring 2010 Presented by: Josée Ranger-Lacroix SAS Institute.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Ch 21 Command Syntax Using the DIR Command with Parameters and Wildcards.
Introduction to SAS BIO 226 – Spring Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.
Hello SAS 9.4: What's New? ChrIs Hemedinger, SAS.
RTSUG 04Feb2014: Beyond Directory Listings in SAS By: Jim Worley.
®® Microsoft Windows 7 for Power Users Tutorial 13 Using the Command-Line Environment.
A Brief Introduction to Stata(1). 1. Getting Started.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Using Advanced INPUT Techniques Peter Cosette Dave Hall Amy Dunn-Ruiz Eric Lyon.
Lesson 17 Getting Started with Access Essentials
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Chapter 1: Introduction to SAS  SAS programs: A sequence of statements in a particular order  Rules for SAS statements: –Every SAS statement ends in.
Chapter 7 File I/O 1. File, Record & Field 2 The file is just a chunk of disk space set aside for data and given a name. The computer has no idea what.
Define your Own SAS® Command Line Commands Duong Tran – Independent Contractor, London, UK Define your Own SAS® Command Line Commands Duong Tran – Independent.
1 EPIB 698E Lecture 1 Notes Instructor: Raul Cruz 7/9/13.
Introduction to Unix (CA263) File Editing By Tariq Ibn Aziz.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
® IBM Software Group © 2006 IBM Corporation JSF Rich Text Area Component This Learning Module describes the use of the JSF Rich Text Area component – for.
Welcome! Welcome! Agenda - Wednesday  Introduction  Installation Tips  New Client Features  New Application Design Features  Installing Chart Director.
Visual Basic for Application - Microsoft Access 2003 Finishing the application.
Copyright © 2004, SAS Institute Inc. All rights reserved. SASHELP Datasets A real life example Barb Crowther SAS Consultant October 22, 2004.
THE C PROGRAMMING ENVIRONMENT. Four parts of C environment  Main menu  Editor status line and edit window  Compiler message window  “Hot Keys” quick.
Do not put content on the brand signature area NOBS for Noobs David B. Horvath, CCP, MS PhilaSUG Winter 2015 Meeting NOBS for Noobs.
Object-Oriented Application Development Using VB.NET 1 Chapter 13 Introduction to Data Access Classes and Persistence.
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.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
TOPSpro Special Topics I: Database Managemen t. Agenda for Module I: Database Management  TOPSpro Backup/Restore Wizard  TOPS-TOPS Import/Export Wizard.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 14 & 19 By Tasha Chapman, Oregon Health Authority.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Working Efficiently with Large SAS® Datasets Vishal Jain Senior Programmer.
Build your Metadata with PROC CONTENTS and ODS OUTPUT Louise S. Hadden Abt Associates Inc.
Better Metadata Through SAS® II: %SYSFUNC, PROC DATASETS, and Dictionary Tables.
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.
D Copyright © 2009, Oracle. All rights reserved. Using SQL*Plus.
A Guide to SQL, Seventh Edition
SQL and SQL*Plus Interaction
Using SQL*Plus.
© 2016, Mike Murach & Associates, Inc.
IS444: Modern tools for applications development
IS444: Modern tools for applications development
Command Syntax Chapter 2 Using the DIR Command with
Using SQL*Plus.
Chapter 18: Modifying SAS Data Sets and Tracking Changes
Topics Introduction to File Input and Output
Exploring Microsoft Excel
Chance to make SAS-L History!
Lisa Mendez, PhD & Andrew Kuligowski
Using SQL*Plus.
Stata Basic Course Lab 2.
Topics Introduction to File Input and Output
Automate & Zip files Using MACRO
Presentation transcript:

1 Back Up with Each Submit One approach for keeping a dynamic back up copy of your current work

2 Introduction Aim: To develop an automated process to save the contents of the editor window to a back up file every time code is submitted Use: To keep an updated copy of all code submitted in case of loss from crashing the SAS session or overwriting files Concepts: PC SAS, windows platform, enhanced editor window Submitting code using a shortcut key: Single back up file overwritten with each submit Rolling back up files

3 Back Up File: Rewriting Over One File Save the contents of the editor window with each submit Submit code using a shortcut key Assign commands to the shortcut key in the keys window: clear log; clear out; file ‘c:\backup\lastprog.sas’ replace; submit; Advantages: Neat and easy to implement Keeps a back up of current work Disadvantages: Can overwrite the back up before retrieving lost code

4 Rolling Back Up Files Concepts: Submit code in enhanced editor window using a shortcut key Shortcut key runs a saved SAS program from the PGM window Entire contents of enhanced editor window are saved to a back up file Submitted code is run 10 back up files are created and sequentially overwritten, oldest first Program contains PIPE device type with filename statement, SAS code and DM commands

5 PIPE Device Type Execute operating system commands directly through the FILENAME statement For example, get file properties from a directory on your c: drive filename backup pipe 'dir C:\backup /t:w /a:-d /OD'; /t:w – time last written /a:-d – file information only, not directories /OD – order = oldest files first

6 PIPE Device Type Use the fileref ‘backup’ to reference information gathered. Volume in drive C has no label. Volume Serial Number is 4C53-A158 Directory of C:\backup 19/09/ :24 2,362 bprog.sas 30/01/ :25 55 backup2.sas 30/01/ :25 55 backup3.sas 30/01/ :25 55 backup4.sas 30/01/ :25 55 backup5.sas 30/01/ :25 55 backup6.sas 30/01/ :25 55 backup7.sas 30/01/ :25 55 backup8.sas 30/01/ :25 55 backup9.sas 30/01/ :25 55 backup10.sas 30/01/ :25 55 backup1.sas 11 File(s) 2,912 bytes 0 Dir(s) 27,278,381,056 bytes free

7 DM Commands Control the windows (output, log, enhanced editor, program editor) and their contents Enter on the command line, use in conjunction with shortcut keys for commonly used commands clear out; clear log; resize; pgm Can also be run from editor window dm 'wpgm; file "c:\backup\backup1.sas" replace;’;

8 Rolling Back Up Files Advantages: Much less chance of overwriting lost code Limitations: Takes a little longer to run with first submit A small line of code appears in the log ** Submitting program **; dm 'cle log; sub;'; The PGM window will briefly open when you ‘submit’ You must specify the data set name when you run procedures if you are running your code piece by piece

9 Rolling Back Up Files - Example Keys: Type KEYS on the command line in SAS Chose an unused shortcut key Type the following commands: pgm; inc ‘c:\backup\bprog.sas’; submit; These commands result in moving from the enhanced editor window to the program editor window, including bprog.sas in the program editor window and submitting the program.

10 Rolling Back Up Files - Example Code: %let bck=1; Initialize macro variable filename backup pipe 'dir C:\backup /t:w /a:-d /OD'; Create data set from backup fileref, keep names and order data backup(keep=fname orda); infile backup missover pad length=len; line $varying200. len; if index(upcase(line),' BACKUP'); fname=input('B'||scan(compress(upcase(line)),2,'B'),$20.); orda+1; run;

11 Rolling Back Up Files - Example Code (continued): Create table backup1 containing names, order and the total number of backup files already in existence proc sql; create table backup1 as select (select max(input(reverse(scan(reverse(fname),2,'.P')),3.)) from backup) as maxnum, a.* from backup a; quit;

12 Rolling Back Up Files - Example Code (continued): Select first observation from backup1 data set (oldest file) If not all 10 files in existence create macro variable as oldest file number +1 If all 10 files in existence create macro variable as number of oldest file data _null_; set backup1 (obs=1); if maxnum lt 10 then call symput('bck',compress(put(maxnum+1,2.))); else call symput('bck',compress(reverse(scan(reverse(fname),2,'.P')))); run;

13 Rolling Back Up Files - Example Code (continued): Tidy up and delete work data sets no longer required proc datasets lib=work; delete backup backup1; quit; run; Run DM commands (see next 2 slides for details) dm 'wpgm; file "c:\backup\backup&bck..sas" replace; %symdel bck; resi; cle out; pgm off' editor; ** Submitting program **; dm 'cle log; sub;';

14 DM commands WPGM - moves to the enhanced editor window FILE - saves the contents of the current window to the specified file RESI - abbreviated command for RESIZE, will return the enhanced editor window to your standard sizing CLE OUT - abbreviated command for CLEAR OUT, clears the output window PGM OFF - shuts the program editor window as this is no longer required EDITOR - ensures the program editor window closes as it is opened when commands are run from the enhanced editor window dm 'wpgm; file "c:\backup\backup&bck..sas" replace; %symdel bck; resi; cle out; pgm off' editor;

15 DM commands CLE LOG - abbreviated command for CLEAR LOG, clears the log window SUB - abbreviated command for SUBMIT, submits the contents of the enhanced editor window ** Submitting program **; dm 'cle log; sub;';

16 Summary Rolling back up files are useful! PIPE device-type is handy for file management activities There are endless ways to control your SAS environment using DM commands Code can be customized to suit your SAS editor window preferences Suggested enhancements: Add code to zip and files periodically Add code to copy to a server