1 / 11

Robo -SAS Coding? Yes! We can auto-generate SAS codes from a SAS data set

Robo -SAS Coding? Yes! We can auto-generate SAS codes from a SAS data set. By Robert Williams Senior Supply Chain Analyst Strategic Sourcing and Contracts The New York Times Company – Shared Service Center. Overview. Example PROC REPORT for Director

magnar
Télécharger la présentation

Robo -SAS Coding? Yes! We can auto-generate SAS codes from a SAS data set

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Robo-SAS Coding? Yes! We can auto-generate SAS codes from a SAS data set By Robert Williams Senior Supply Chain Analyst Strategic Sourcing and Contracts The New York Times Company – Shared Service Center

  2. Overview • Example PROC REPORT for Director • Needs same reports for each manager by dept ID • Possible ways to generate reports by dept • 1 – Copy and paste PROC REPORT codes for each dept ID • 2 – Use SAS macros with dept ID • 3 – Dynamically generate PROC REPORTS codes using dept ID variable (RoboCoding) • Q&A

  3. Example of Directors Report • Director wants to know how many minutes, data usage and text messaging for all his employees by department. • It is a PROC REPORT code to generate the PDF report. See next slide for the example.

  4. Example of Directors Report

  5. Same reports by Dept ID? • What if the Director wants to distribute the same reports to every department head? • The Director wants it in separate PDF reports for each department manager responsible for their employees.

  6. Separate PDF reports? How? • 1 – We can copy and paste the PROC REPORT codes and add the WHERE statement for each department. • 2 – Or, we can use SAS macros that includes the PROC REPORT codes and use department ID as a marco variable. • 3 – Or, we can dynamically generate PROC REPORT codes using dept ID from a SAS data set (RoboCoding)

  7. RoboCoding • Why do we need to dynamically generate the SAS code by dept ID? • With copy and paste or using SAS macros, we have to get an exhaustive listing of all the department IDs. This is ok if we have only a few departments. • But if we have about 100 departments, dynamically generating the SAS code by dept ID is the way to do this. • If used as a monthly report, it may not have the same groups of departments each month.

  8. RoboCoding • Several key points how to dynamically create SAS codes from SAS data sets • Making a listing of all dept IDs using PROC FREQ with output to SAS data set • Use DATA _NULL_ to create a temporary SAS program file • In the DATA_NULL_ use ‘put’ statements to include the PROC REPORT codes for each line as well as the WHERE statements. • Run the temporary SAS program file.

  9. RoboCoding Sample Code

  10. Q&A • Questions? • Contact: Robert Williams The New York Times Company Shared Service Center 101 West Main Street, Suite 2000 Norfolk, VA 23510 robert.williams@nytssc.com

  11. References • SAS Certification Prep Guide: Base Programming for SAS 9by SAS Institute Inc. , Cary, NC. • SAS Online Doc Version 9.2. Cary, NC: SAS Institute Inc.

More Related