A Useful Footnote Martha Cox Population Health Research Unit Community Health & Epidemiology Dalhousie University Good morning. We've all had this happen:

Slides:



Advertisements
Similar presentations
Chapter 9: Introducing Macro Variables 1 © Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Advertisements

Today: Run SAS programs on Saturn (UNIX tutorial) Runs SAS programs on the PC.
SW318 Social Work Statistics Slide 1 Using SPSS for Graphic Presentation  Various Graphics in SPSS  Pie chart  Bar chart  Histogram  Area chart 
Other Features Index and table of contents Macros and VBA.
Computing for Research I Spring 2014 January 22, 2014.
CPS120: Introduction to Computer Science
SAS Workshop Lecture 1 Lecturer: Annie N. Simpson, MSc.
Manipulating Text In today’s lesson we will look at: why we might want to pick out parts of text strings some BASIC functions that can be used to chop.
June 12, 2009 Toronto Area SAS Society 1 What’s new in BASE SAS 9.2 Checkpoint/Restart Rupinder Dhillon Dhillon Consulting Inc.
Chapter 4 concerns various SAS procedures (PROCs). Every PROC operates on: –the most recently created dataset –all the observations –all the appropriate.
An Introduction to Forms. The Major Steps of a MicroSoft Access Database  Tables  Queries  Forms  Macros  Reports  Modules On our road map, we are.
Copyright © 2010, SAS Institute Inc. All rights reserved. SAS ® Using the SAS Grid.
FORMAT statements can be used to change the look of your output –if FORMAT is in the DATA step, then the formats are permanent and stored with the dataset.
National Diploma Unit 4 Introduction to Software Development Procedures and Functions.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapter 25 By Tasha Chapman, Oregon Health Authority.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 3 & 4 By Tasha Chapman, Oregon Health Authority.
Creative Create Lists Elizabeth B. Thomsen Member Services Manager
CSC 108H: Introduction to Computer Programming Summer 2011 Marek Janicki.
Output THE BASICS. What is Output? Output is the information that comes FROM a computer OUT to a user Sometimes this information is feedback to an action.
JavaScript Part 1 Introduction to scripting The ‘alert’ function.
BIT116: Scripting Lecture 05
AUDITING Elysa Hartati.
Hidden Slide for Instructor
Development Environment
AP CSP: Cleaning Data & Creating Summary Tables
CS 106 Computing Fundamentals II Chapter 5 “Excel Basics for Windows”
More about comments Review Single Line Comments The # sign is for comments. A comment is a line of text that Python won’t try to run as code. Its just.
Expanding and Factoring Algebraic Expressions
Whatcha doin'? Aims: To start using Python. To understand loops.
SQL and SQL*Plus Interaction
Introduction to Python
Two “identical” programs
Lab: ssh, scp, gdb, valgrind
Chapter 16 – Programming your App’s Memory
Preparing to present your poll Your pre-presentation checklist
Makefile Tutorial CIS5027 Prof: Dr. Shu-Ching Chen
Microsoft Build /10/2018 1:35 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
Managing Your Literature Search Using Zotero
IPC144 Introduction to Programming Using C Week 2 – Lesson 1
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Instructor: Raul Cruz-Cano
Module 6: Preparing for RDA ...
Learning Objective LO: We’re learning to understand when it is appropriate to use particular data types.
Conditional Processing
Tamara Arenovich Tony Panzarella
Working with Text and Numbers in Java
Microsoft Word - Formatting Pages
Chapter 7: Macros in SAS Macros provide for more flexible programming in SAS Macros make SAS more “object-oriented”, like R Not a strong suit of text ©
Creating Macro Variables and Assigning Value
Integrating CSC into our Schedules
In Class Program: Today in History
Building Web Applications
Microsoft® Small Basic
Introduction to SAS A SAS program is a list of SAS statements executed in order Every SAS statement ends with a semicolon! SAS statements can be in caps.
Coding Concepts (Data Structures)
Defining and Calling a Macro
Staying Safe at School ALICE TRAINING for STUDENTS: ELEMENTARY LEVEL :Derived from Akron City Schools Teacher talk is in BOLD. Modify wording if needed.
I know that what I say and do can affect my friends
Learning VB2005 language (basics)
Quarter 1.
Using screens and adding two numbers - addda.cbl
Staying Safe at School ALICE TRAINING for STUDENTS: ELEMENTARY LEVEL :Derived from Akron City Schools Teacher talk is in BOLD. Modify wording if needed.
Exceptions 10-May-19.
Tips and Tricks for Using Macros to Automate SAS Reporting.
Strings and Dates in JavaScript
I think the... came first because...
Working with dates and times
Presentation transcript:

A Useful Footnote Martha Cox Population Health Research Unit Community Health & Epidemiology Dalhousie University Good morning. We've all had this happen: Client walks into your office with a wrinkled, coffee-stained report supposedly prepared by your group some time ago and asks you to prepare an update. Wouldn't it be nice if the report could tell you how and when it was produced, and by whom? Today I'm going to show you how to make a footnote that will do just that. In the process, I'll introduce a number of features of SAS that may be new to you. And, since John is holding me to the 10 minute "Techie Tip" timeframe, you'll get to go explore more about these new things for yourself.

Make the output tell you where it came from Program Name Date and time it was submitted Who ran it So, let's say there are three things we'd like to know about this mystery output: the name of the program that produced it the date and time the program ran and the person who ran it

Program Name SAS system option SYSIN Specifies the default location of SAS source programs SAS function GETOPTION Returns the current value of the specified system or graphics option Start with the program name. You can use the systems option SYSIN to specify where SAS should look for source programs. But we want to get the current value of SYSIN. A SAS function called GETOPTION will do that for us. (Feature #1 to explore on your own) Functions are great if you're in the middle of a data step. But a footnote statement is not a data step. So how can we use GETOPTION? getoption(sysin) → full operating system path & filename

a way to execute a data step function without being in a data step %SYSFUNC a way to execute a data step function without being in a data step If the result might contain special characters or mnemonic operators, use %QSYSFUNC instead. A SAS Macro function called %SYSFUNC can be used anywhere to execute a data step function. (Feature #2 to explore on your own) If you think the value you're retrieving might contain special characters, then %QSYSFUNC will tell the macro compiler to treat those characters as part of your text instead of responding to them. Since the full path and filename will definitely contain characters like :, /, \, or [ ], we need to use %QSYSFUNC. So . . .

%qsysfunc(getoption(SYSIN)) Program Name %qsysfunc(getoption(SYSIN)) This is the code for the first part of what we want.

Date and Time the program was submitted The next piece of information that we want is the date and time the program was submitted. We could get this by using SAS automatic macro variables...

Automatic Macro Variables &sysdate 19OCT07 &sysdate9 19OCT2007 &systime 16:22 &sysuserid MCOX &sysvlong 8.02.02M0P012301 SAS provides over 35 automatic macro variables that give you information about your session. (Feature #3 to explore on your own) Here are a few that we might use in our footnote. The date and time, the user who submitted it, even which version of SAS was used. Personally, I like &sysdate9 since it’s unambiguous. No worries about whether the month or the day comes first. But John hates it. So we’ll use &systime, which is in a format he likes. And I have a different method we can use for John’s date.

Date Submitted %sysfunc(today(), yymmddD10.) The function TODAY() is a SAS function that returns today's date – the same value as &SYSDATE. %SYSFUNC lets us call this function and provide whatever SAS date format we want. This format gives us year-month-day using a dash as a separator. (Feature #4 to explore on your own) So the result is like the ISO 8601 date format that John favors.

Who Ran The Program SAS Automatic Macro Variable: &sysuserid This variable has a length of 12. "MCOX " So to use it in a sentence, we need to trim it. The last thing we wanted to know was who ran the program. You saw on a previous slide that there's a SAS automatic macro variable which gives us this: &sysuserid. Unfortunately, SAS stores this as a character value of a specific length (I think it's 12). So we need to trim it. We already talked about calling a function. So . . .

%sysfunc(trim(&sysuserid)) Who Ran The Program %sysfunc(trim(&sysuserid)) . . . here's the code for our third piece. Now let's put it all together.

Putting it all together proc freq data=shrug.sample; tables sex; footnote1 "Program: %qsysfunc(getoption(SYSIN)) submitted %sysfunc(today(), yymmddD10.) at &systime. by %sysfunc(trim(&sysuserid))."; run; Here's code for a simple PROC FREQ using our new footnote. Remember, when you do this, the whole string in the footnote has to be on the same line. I've broken it here so it fits on the slide.

The Results (VMS batch job) The FREQ Procedure Patient Gender Cumulative Cumulative sex Frequency Percent Frequency Percent -------------------------------------------------------- F 4 40.00 4 40.00 M 6 60.00 10 100.00 Program: DISK$USER1:[MCOX.SHRUG]FOOTVMS.SAS;21 submitted 2007-10-12 at 17:42 by MCOX. And here's the result. Now a few caveats. This program was run in batch on VMS.

Notes about Display Manager SYSIN is blank &systime = the time you started your SAS session; not when that bit of code was run &sysuserid = the 'registered' PC user (See Control Panel → System.) If you are running your program in Display Manager mode: SYSIN will be blank because SAS is using code from the Editor window and doesn't look outside for source code Also, &SYSTIME is the time you fired up Display Manager. If you do this first thing Monday morning and leave your PC running all week, this variable isn't going to help you pinpoint when a particular program was run. If you are running on a PC, the value of &SYSUSERID will be the value of "registered user" To see what this is on your machine, go to Control Panel and click System. Mine is "PHRU6" – which doesn't really help someone figure out Martha ran the program.

Questions? I have a one-page handout with just the FOOTNOTE statement if you want to grab one on your way out. Any questions?