TIPS AND TRICKS: IMPROVE EFFICIENCY TO YOUR SAS PROGRAMMING

Similar documents
Moving Data and Results Between SAS and Excel. Harry Droogendyk Stratia Consulting Inc.

Creating a Directory with a Mail Merge from an Excel Document

ET01. LIBNAME libref <engine-name> <physical-file-name> <libname-options>; <SAS Code> LIBNAME libref CLEAR;

Survey Design, Distribution & Analysis Software. professional quest. Whitepaper Extracting Data into Microsoft Excel

EQuIS Data Processor (EDP) User Manual

USING the IEDATA add-in FROM THE SPREADSHEET MENU

Using Dynamic Data Exchange

The Basics of PROC FCMP. Dachao Liu Northwestern Universtiy Chicago

How to Set up a Budget Advanced Excel Part B

Lab 7 Macros, Modules, Data Access Pages and Internet Summary Macros: How to Create and Run Modules vs. Macros 1. Jumping to Internet

Technical White Paper

Power Query for Parsing Data

Identifying Updated Metadata and Images from a Content Provider

HO-1: BASIC SPREADSHEET SKILLS - CREATING A WORKBOOK

One SAS To Rule Them All

Unit 3 Fill Series, Functions, Sorting

Unit 3 Functions Review, Fill Series, Sorting, Merge & Center

Using Excel to Troubleshoot EMIS Data

Congratulations. EPG Workshop

Explore commands on the ribbon Each ribbon tab has groups, and each group has a set of related commands.

ST Lab 1 - The basics of SAS

University of North Dakota PeopleSoft Finance Tip Sheets. Utilizing the Query Download Feature

If the list that you want to name will change In Excel 2007 and later, the easiest way to create.

Workshop. Import Workshop

Choosing the Right Tool from Your SAS and Microsoft Excel Tool Belt

This lesson is part 5 of 5 in a series. You can go to Invoice, Part 1: Free Shipping if you'd like to start from the beginning.

MIS 0855 Data Science (Section 006) Fall 2017 In-Class Exercise (Day 18) Finding Bad Data in Excel

Excel Timesheet Upload into CATS. Category 1 : Time Management Category 2 : Personnel Time Recording. Work Instruction

Chapter 2 The SAS Environment

Clearspan OpEasy Basic Provisioning Guide

Hooking up SAS and Excel. Colin Harris Technical Director

Chemistry 30 Tips for Creating Graphs using Microsoft Excel

Lab 1. Introduction to R & SAS. R is free, open-source software. Get it here:

Principles of Automation

Become strong in Excel (2.0) - 5 Tips To Rock A Spreadsheet!

3. Data Tables & Data Management

The main differences with other open source reporting solutions such as JasperReports or mondrian are:

Microsoft Excel 2010 Training. Excel 2010 Basics

Excel 2007 Pivot Table Include New Items Manual Filter

Building a Waterfall Chart in Excel

BUILDING A WATERFALL CHART IN EXCEL

Excel Training - Beginner March 14, 2018

Importing Local Contacts from Thunderbird

Creating a Mail Merge Document

Microsoft Excel 2007 Macros and VBA

Biology 345: Biometry Fall 2005 SONOMA STATE UNIVERSITY Lab Exercise 2 Working with data in Excel and exporting to JMP Introduction

Advanced Excel Charts : Tables : Pivots

Light Speed with Excel

Database Manual Suite Version 2.8. Page 1 of 82. Noventri Suite Database Manual SF REV 03 3/21/14

Chapter 2 Assignment (due Thursday, April 19)

Basic tasks in Excel 2013

GiftWorks Import Guide Page 2

QUICK EXCEL TUTORIAL. The Very Basics

Taming a Spreadsheet Importation Monster

Creating an Excel Pivot Table Manually

TMS TPlannerExport DEVELOPERS GUIDE

Excel Tips and Tricks. Andrew J. Wright (2014);

Use mail merge to create and print letters and other documents

Using a Fillable PDF together with SAS for Questionnaire Data Donald Evans, US Department of the Treasury

DOWNLOAD PDF MICROSOFT EXCEL ALL FORMULAS LIST WITH EXAMPLES

Report Commander 2 User Guide

Part-time Payroll Changes: Guide for Budget Officers

User Manual Mail Merge

Computer & Careers Mr. Lewis

Advanced Excel Macros : Data Validation/Analysis : OneDrive

EXCEL IMPORT user guide

A Quick Trick for Hiding Duplicate Excel Values

Advanced Training Manual: Surveys Last Updated: October 2013

Making use of other Applications

2008 TIPS and TRICKS LAW CONFERENCE

Excel: Tips and Tricks Speaker: Marlene Groh, CCE, ICCE Date: June 13, 2018 Time: 2:00 to 3:00 & 3:30 to 4:30 Session Number: & 27097

Writing Programs in SAS Data I/O in SAS

Excel Time Savers Page 1

Reference Guide. Adding a Generic File Store - Importing From a Local or Network ShipWorks Page 1 of 21

Introduction to Microsoft Office 2007

Excel 2010 Formulas Don't Update Automatically

Guide Of Excel 2007 In A List Drop Down Create Conditional

More Skills 12 Create Web Queries and Clear Hyperlinks

Note: Act Today provide this KB article as a courtesy however accept no responsibility for content or the recipient performing these steps

How to Remove Duplicate Rows in Excel

Insert Page Break Excel 2007 Not Working >>>CLICK HERE<<<

Formulas, LookUp Tables and PivotTables Prepared for Aero Controlex

Stored Processes What are they and how can they be used? Adam Player (Nerd)

Microsoft Project 2010 Manual Files Will Not Open

Chapter 28 Saving and Printing Tables. Chapter Table of Contents SAVING AND PRINTING TABLES AS OUTPUT OBJECTS OUTPUT OBJECTS...

Introductory Excel. Spring CS130 - Introductory Excel 1

MS Excel VBA Class Goals

Using Graph-N-Go With ODS to Easily Present Your Data and Web-Enable Your Graphs Curtis A. Smith, Defense Contract Audit Agency, La Mirada, CA

My Top 5 Formulas OutofhoursAdmin

Mail & Deploy Reference Manual. Version 2.0.5

Paper ###-YYYY. SAS Enterprise Guide: A Revolutionary Tool! Jennifer First, Systems Seminar Consultants, Madison, WI

Sending SAS Data Sets and Output to Microsoft Excel

2 Spreadsheet Considerations 3 Zip Code and... Tax ID Issues 4 Using The Format... Cells Dialog 5 Creating The Source... File

Workbooks (File) and Worksheet Handling

Microsoft Office Illustrated. Getting Started with Excel 2007

Generating a Custom Bill of Materials

Importing and Exporting Data

WPS Workbench. user guide. "To help guide you through using the WPS user interface (Workbench) to create, edit and run programs"

REPORTING Copyright Framework Private Equity Investment Data Management Ltd

COPYRIGHTED MATERIAL. Making Excel More Efficient

Transcription:

TIPS AND TRICKS: IMPROVE EFFICIENCY TO YOUR SAS PROGRAMMING Guillaume Colley, Lead Data Analyst, BCCFE Page 1

Contents Customized SAS Session Run system options as SAS starts Labels management Shortcut keys Coding Tips Import data from Excel in 1 line Export table/output to Excel Sub-group analysis in 1 step User functions Output statement to duplicate rows Page 2

Customized SAS session You can make SAS run system options by default every time SAS starts up. Open C:\Program Files\SASHome\SASFoundation\9.3\nls\en\sasv9.cfg Page 3

Customized SAS session Can be any system option; from APPEND to YEARCUTOFF PAGESIZE, DATESTYLE, FMTSEARCH, CMPLIB A recommended option to set-up as default is MERGENOBY By default, SAS will not say anything if you perform a MERGE without a BY statement This option forces SAS to tell you that something is wrong (you can choose warning or error) Page 4

Customized SAS session Getting rid of labels (because these are really annoying, aren t they?) Proc datasets: You can make SAS explorer show variable names by default: Select SAS explorer, then go Tools, Options, Explorer Page 5

Customized SAS session Select the «Members» tab, Table &Open Add the following to the end of the action command: COLHEADING= NAME Page 6

Customized SAS session Setting up shortcut keys Upper and lower case selection Extend selection Comment and Uncomment selection With the Editor being active: Tools, Options, Enhanced Editor Keys Page 7

Coding Tips Import multiple Excel sheets in 1 line libname XL excel "C:\Temp\MyExcelFile.xlsx"; Your library name Library type Excel file path Will appear as a library and each worksheet will appear as a table Need to use name literals to be able to work with the above tables: Use: xl.'morestuff$'n xl.morestuff$ will not work Page 8

Coding Tips Export into Excel Why you don t need to bother with labels, formatting, and try to make a SAS output look nice: It is faster and easier to format your output in an Excel spreadsheet, and it makes it more workable/re-usable Sas output is not going to look nice anyway One-time only exports: Tables: right click on the table in the explorer, View in Excel Proc output: use the Output Delivery System (ODS): ODS HTML FILE="C:\Users\Guillaume\Desktop\TEMP.xls"; /* Any proc which exports something to the output window would work */ proc contents data=pcs_all; run; ods html close; Many different options if you want to customize your ODS output Page 9

Export into Excel Recurring exports: Coding Tips Spend time getting a nicely formatted Excel document Use Dynamic Data Exchange (DDE) to make SAS write your results exactly where you want in your opened Excel spreadsheet: filename name dde excel Sheet1!r6c2:r9c4 ; Defines where you are going to write your SAS data in Excel: sheet, top left cell and bottom right cell data _null_; set test; name of SAS table to export file name; previously assigned filename put var1 var2 var3 etc.; run; Writes your SAS data in the specified location Page 10

Coding Tips Sub-group analysis in 1 step You can use complex WHERE statements in data step headers or proc headers To avoid the creation of sub-population tables Page 11

Coding Tips User functions You can create, test, and store SAS subroutines, then use them in other SAS procedures or DATA steps $ if the function returns a character variable (numeric otherwise) Function compiler (FCMP) doesn't need a "run" Page 12

User functions example Coding Tips If you want to use an array as argument you need to specify the VARARGS option Page 13

Coding Tips Output in a data step Implicit output VIRLOAD data set TEST data set PATIENTID DATE VIRLOAD PATIENTID DATE VIRLOAD LN_VL Explicit output The OUTPUT statement tells SAS to write the current observation to a SAS data set immediately, not at the end of the DATA step HIGH_VL dataset VIRLOAD data set PATIENTID DATE VIRLOAD LN_VL PATIENTID DATE VIRLOAD LOW_VL dataset PATIENTID DATE VIRLOAD LN_VL Page 14

Coding Tips Using explicit output to duplicate rows Weekly dataset to convert in a daily dataset WEEKLY data set DAILY data set id episode dt id episode dt 100041 1 19-Jul-06 100041 1 19-Jul-06 100041 1 26-Jul-06 100041 1 18-Jul-06 100041 1 2-Aug-06 100041 1 17-Jul-06 100041 1 9-Aug-06 100041 1 16-Jul-06 100041 1 20-Jan-10 100041 1 15-Jul-06 100041 1 14-Jul-06 100041 1 13-Jul-06 100041 1 26-Jul-06 100041 1 25-Jul-06 100041 1 24-Jul-06 100041 1 23-Jul-06 100041 1 22-Jul-06 100041 1 21-Jul-06 100041 1 20-Jul-06 100041 1 2-Aug-06 100041 1 1-Aug-06 100041 1 31-Jul-06 Page 15

Thank you Page 16