Title: How to Optimize Existing SAS
1How to Optimize Existing SAS Programsfor
Generating Standard Reports
- Â
- Teo Gamishev
- Office of Research and Statistics Columbia, SC
2Whats in this topic?
- Most common practice on generating Standard
Reports - Is that a problem and how to get out of it?
- What is the advantage of Optimization?
- Step-By-Step Guide
3Most common practice on generating Standard
Reports
- The basic steps of generating standard reports
include all or some of the following processes - Generating data extracts
- Downloading the extracts
- Importing the data into SAS
- Updating the existing database
- Generating the Reports
4Most common practice on generating Standard
Reports
- Open the existing SAS program to change
- numerous dates
- variable names
- data set names
- file names
- titles
- Submit each one program
- Check for errors and move to the next program
5Is that a problem?
- Somebody may try to convince you that this job
is - very inspiring
- very creative
- makes you happy
- takes a Bachelor or Master degree to get it?
6How to get out of that situation?
- Use the available SAS tools to automate the
process of updating the programs, completely - In this presentation youll find just one of many
affordable ways to do it
7What is the advantage of Optimization?
- By applying that method, the time for just one
- of the standard report processes, has been
reduced - from 13 hours programmers time to 3 clicks
- of the mouse.
- Â
- The overall outcome is creating
- ERROR FREE
- standard reports for a significantly shorter
time. - Â
- The programmer is focused on
- quality control and researching the data.
8Â Step-By-Step Guide
- Step One Creating driving SAS program(s)
- Step Two Modifying the existing SAS programs
- Â
- What do you need to know?-The places within the
programs, where the changes occur. - Â
- You dont need to have a deep knowledge about the
logic within the programs.
9Step-By-Step Guide Step One Creating DRIVING
SAS Programs
- A simple approach suggests grouping all programs
performing a similar task. - Â
- Example
- All JCL/SAS programs, generating the extracts on
the Mainframe - All SAS programs, importing the data files into
SAS tables - All SAS programs updating the main database(s)
- All SAS programs, generating the Reports
10Step-By-Step Guide Step One Creating DRIVING
SAS Programs
- Create a new SAS Program DRIVING code
- The purpose of the DRIVING code is
- generate all macro variables youll need for the
programs within that particular group - create all new folders to export data or reports
- trigger all SAS programs within the same group
11Step-By-Step Guide Generate all macro variables
youll need for the programs within that
particular group
- Example
- LET DATAMONTH 01mar2008 Your
typing ends here!!! - Data _null_
- first day of the data month
- dmfirst INTNX ('month',DATAMONTHd,0)
-
- last day of the data month
- dmlast INTNX ('month',DATAMONTHd,0,'end')
- Â
- oylast INTNX ('month', dmfirst,-12)
- oylast INTNX ('month', dmfirst,-12,'end')
- Â
- BAD EXAMPLE
- dmfirst INTNX('month',today(),-1)
- dmlast INTNX('month',today(),-1,'end')
12Step-By-Step Guide Generate all macro variables
youll need for the programs within that
particular group
- Example
- Â
- call symput('DMFD',put((dmfirst),DATE9.))
- call symput('BDMN',trim(left(put((bdmlast),
MONNAME.)))) - call symput('CMFD', trim(left(put((cmfirst),
DAY.)))) - call symput('YBDY', put((bdmlast), YEAR4.))
- call symput('DMMYY', put((dmfirst), MONYY5.))
- call symput('MM', put(month(dmlast), z2.))
- call symput('YY', put(dmfirst, year2.))
- put _user_
13Step-By-Step GuideCreate all new folders
- Example
- Â
- FILENAME lynn PIPE "mkdir ""E\DSP\ReportsDMMYY."
"" - data _null_
- infile lynn
- run
- Â
- Â
- Trigger all SAS programs within the same group
- Â
- Example
- Â
- include 'E\DSP\cap\Programs\01a.sas'
- include 'E\DSP\cap\Programs\01a_pt2.sas'
14Step-By-Step Guide Step Two Modifying the
existing SAS programs
- replace all dates, variable names, datasets names
and titles with the macro variables created
within the DRIVING program - create destination for the outputs/logs and
redirect the output using - PROC PRINTTO for text files
- ODS.TAGSET for Excel files
15Step-By-Step Guide Step Two Modifying the
existing SAS programs
- Now is the time to solve all of the challenges
like - Â
- How to update the JCL/SAS programs from SAS
- How to automate the data downloading process
- How to control the flow of the SAS program
- How to create custom time periods, like fiscal or
state years - How to automatically create new data set in the
beginning of the new time period - How to generate custom date FORMATs and INFORMATs
- How to read large number of datasets located in
the same folder - How to clean variables from bugs
- How to zip the data or the reports from within
SAS - How to clean the temp data and the macro
variables
16The Trigger ProgramTHE RUNNER
17Â Thank you
- References
- How to Optimize Existing SAS Programs for
Generating Standard Reports, Teo Gamishev - Â
- Affordable SAS Tips, Teo Gamishev
- Â
- Look for the articles in the membership area,
- coming next month!
18South Carolina SAS Users Group