Tips & Tricks MASUG02/18/2005. Multiple Graphs on One Page.

Slides:



Advertisements
Similar presentations
Haas MFE SAS Workshop Lecture 3:
Advertisements

Summary Statistics/Simple Graphs in SAS/EXCEL/JMP.
Zhongmin Li and Geeta Mahendra
TABLES and FIGURES BIOL 4001.
Using ODS Regions to Create Custom Reports Kate Morrow, M.S. Statistician Vermont Oxford Network, Burlington, VT.
Why ROOT?. ROOT ROOT: is an object_oriented frame work aimed at solving the data analysis challenges of high energy physics Object _oriented: by encapsulation,
Outline Proc Report Tricks Kelley Weston. Outline Examples 1.Text that spans columnsText that spans columns 2.Patient-level detail in the titlesPatient-level.
Controlling SAS Graphics using ANNOTATE Datasets Elizabeth Campagna University of Colorado Denver Colorado Health Outcomes Program Colorado Day – Denver.
Dori Baldwin Student Info Mgmt Coordinator Kent ISD.
Exploring Microsoft Access
Excel Graphing Tutorial Lauren Ottaviano Fall 2012.
Introduction to SQL Session 1 Retrieving Data From a Single Table.
How to Build Tabular Dashboards Using Proc Report
Data Preparation for Analytics Using SAS Gerhard Svolba, Ph.D. Reviewed by Madera Ebby, Ph.D.
The gchart Procedure The gchart Procedure is used to create bar charts of various types (it can also create pie charts. It’s most basic form would look.
1 Chapter 3: Macro Definitions 3.1 Defining and Calling a Macro 3.2 Macro Parameters 3.3 Macro Storage (Self-Study)
Computing for Research I Spring 2014 January 22, 2014.
SAS® Maps as Tools to Display and Clarify Healthcare Outcomes Barbara B. Okerson, HMC, Richmond, VA.
SAS SQL SAS Seminar Series
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.
PROC GREPLAY With Templates December 5, 2008 Barry Hong Process Analysis and Simulation U. S. Steel Canada © 2008 United States Steel Corporation.
Ranjeet Department of Physics & Astrophysics University of Delhi Working with Origin.
An Animated Guide©: Sending SAS files to Excel Concentrating on a D.D.E. Macro.
SAS SQL Part 2 Alan Elliott. Dealing with Missing Values Title "Dealing with Missing Values in SQL"; PROC SQL; select INC_KEY,GENDER, RACE, INJTYPE, case.
Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.
Introduction to SAS. What is SAS? SAS originally stood for “Statistical Analysis System”. SAS is a computer software system that provides all the tools.
TS02 SAS GTL - Injecting New Life into Graphs
The introduction to SPSS Ⅱ.Tables and Graphs for one variable ---Descriptive Statistics & Graphs.
Question 10 What do I write?. Spreadsheet Make sure that you have got a printout of your spreadsheet - no spreadsheet, no marks!
Creating and Managing Indexes Using Proc SQL Chapter 6 1.
SAS Macro: Some Tips for Debugging Stat St. Paul’s Hospital April 2, 2007.
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
SAS Mapping functionality to measure and present the Veracity of Location Data.
5/30/2010 SAS Macro Language Group 6 Pradnya Nimkar, Li Lin, Linsong Zhang & Loc Tran.
Macro Overview Mihaela Simion. Macro Facility Overview Definition : The SAS Macro Facility is a tool within base SAS software that contains the essential.
Introduction to SAS/Graph 9.2 Ken Barz Colorado Prevention Center 22Oct2009 Ken Barz Colorado Prevention Center.
1 Efficient SAS Coding with Proc SQL When Proc SQL is Easier than Traditional SAS Approaches Mike Atkinson, May 4, 2005.
Introduction to Enterprise Guide Jennifer Schmidt Rhonda Ellis Cassandra Hall.
ON PATHS LESS TRODDEN… Excursions in SAS/GRAPH ® and PROC TABULATE Presented by Aaron Rabushka © Aaron Rabushka 2000.
Chapter 22: Using Best Practices 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Effective SAS greplay’ing and how to avoid stretching By David Mottershead Senior Programmer, Quanticate.
BMTRY 789 Lecture 10: SAS MACRO Facility Annie N. Simpson, MSc.
Tips & Tricks From your fellow SAS users 9/30/2004.
PROC GPLOT GPLOT is used to make two dimensional scatter-plots. General Syntax: proc gplot data=data-set options; plot y-variable*x-variable/options; run;
LANDESK SOFTWARE CONFIDENTIAL Tips and Tricks with Filters Jenny Lardh.
MASUG September 15, Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks 
Lesson 8 - Topics Creating SAS datasets from procedures Using ODS and data steps to make reports Using PROC RANK Programs in course notes LSB 4:11;5:3.
Chapter 7: Macros in SAS  Macros provide for more flexible programming in SAS  Macros make SAS more “object-oriented”, like R 1 © Fall 2011 John Grego.
1 Chapter 3: Getting Started with Tasks 3.1 Introduction to Task Dialogs 3.2 Creating a Listing Report 3.3 Creating a Frequency Report 3.4 Creating a Two-Way.
Customize SAS Output Using ODS Joan Dong. The Output Delivery System (ODS) gives you greater flexibility in generating, storing, and reproducing SAS procedure.
SAS ® is a very powerful tool when producing Graphics. A single graphical data step can easily create a Kaplan Meier Plot, but there is no single graphical.
SAS/GRAPH The Basics. Today’s Topics GOPTIONS GPLOT GCHART GCONTOUR G3D.
SAS Beyond TFLs: An Application as a Statistician’s Tool William Coar Date: 10/15/2009 Denver SAS User’s Group.
BMTRY 789 Lecture9: Proc Tabulate Readings – Chapter 11 & Selected SUGI Reading Lab Problems , 11.2 Homework Due Next Week– HW6.
Chapter 6: Modifying and Combining Data Sets  The SET statement is a powerful statement in the DATA step DATA newdatasetname; SET olddatasetname;.. run;
PROC CATALOG The Wish Book SAS® Procedure. 2 PROC CATALOG, the Wish Book SAS® Procedure Louise S. Hadden Abt Associates Inc. PROC CATALOG, the Wish Book.
SAS Programming Training Instructor:Greg Grandits TA: Textbooks:The Little SAS Book, 5th Edition Applied Statistics and the SAS Programming Language, 5.
CMS SAS Users Group Conference Learn more about THE POWER TO KNOW ® October 17, 2011 PROC GMAP, HTML and You Thomas Kornfield, CMS.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
EXCEL LESSON 12 CREATING CHARTS VOCABULARY. AXIS A line bordering the chart plot area used as a frame of reference for measurement.
Descriptive Statistics using R. Summary Commands An essential starting point with any set of data is to get an overview of what you are dealing with You.
Behind the Scenes with SAS®: Using Customer Graphics in SAS® Output Louise Hadden Abt Associates Inc.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 16 & 17 By Tasha Chapman, Oregon Health Authority.
Session 1 Retrieving Data From a Single Table
Creating Macro Variables in SQL (Review)
ON PATHS LESS TRODDEN… Excursions in SAS/GRAPH® PROC TABULATE and
Defining and Calling a Macro
3 Iterative Processing.
Summarizing Data with Summary Functions
Trigger %macro check_trigger_run;
Presentation transcript:

Tips & Tricks MASUG02/18/2005

Multiple Graphs on One Page

Often it is useful to put several or even many graphs on one page Often it is useful to put several or even many graphs on one page Graphs are created first and stored in a SAS graphics catalog Graphs are created first and stored in a SAS graphics catalog Using proc greplay a template can be defined and graphic elements put into the various panels Using proc greplay a template can be defined and graphic elements put into the various panels

Defining a template can be tedious Here is the template definition code for a sample 3 panel template: Here is the template definition code for a sample 3 panel template: tdef mytemp tdef mytemp 1 / llx=0 ulx=0 lrx=100 urx=100 lly=0 lry=0 uly=100 ury=100 1 / llx=0 ulx=0 lrx=100 urx=100 lly=0 lry=0 uly=100 ury=100 2 / llx=0 ulx=0 lrx=100 urx=100 lly=65 lry=65 uly=95 ury=95 2 / llx=0 ulx=0 lrx=100 urx=100 lly=65 lry=65 uly=95 ury=95 3 / llx=0 ulx=0 lrx=100 urx=100 lly=35 lry=35 uly=65 ury=65 ; 3 / llx=0 ulx=0 lrx=100 urx=100 lly=35 lry=35 uly=65 ury=65 ; Rather than define the two opposite corners of a rectangle (to define a panel), SAS wants the user to define all four corners of each rectangle (each panel). Rather than define the two opposite corners of a rectangle (to define a panel), SAS wants the user to define all four corners of each rectangle (each panel). Each (x,y) value is repeated twice, opening the door to human error. (Yes, I’ve seen templates with “crooked” panels.) Each (x,y) value is repeated twice, opening the door to human error. (Yes, I’ve seen templates with “crooked” panels.)

PanelDef /********************************************************************* * Name: PanelDef * * Desc: Returns the text for a greplay panel definition. * * Type: Graphics Utility * * History: * * 7/1/04 WJS * *********************************************************************/ %macro paneldef( pnlnbr, leftx, rightx, lowery, uppery, color ); %local return; %local return; %let return = &pnlnbr /; %let return = &pnlnbr /; %let return = &return llx=&leftx ulx=&leftx lrx=&rightx urx=&rightx; %let return = &return llx=&leftx ulx=&leftx lrx=&rightx urx=&rightx; %let return = &return lly=&lowery lry=&lowery uly=&uppery ury=&uppery; %let return = &return lly=&lowery lry=&lowery uly=&uppery ury=&uppery; %if ( %length( &color ) > 0 ) %then %if ( %length( &color ) > 0 ) %then %let return = &return color=&color; %let return = &return color=&color;&return%mend;

Sample Code goptions nodisplay; goptions nodisplay; proc gplot data=rpt gout=&mygout; proc gplot data=rpt gout=&mygout; plot &var * &timevar = 9 / plot &var * &timevar = 9 / grid frame autovref grid frame autovref vaxis = axis1 vaxis = axis1 haxis = axis2 haxis = axis2 name = "Top“ ; name = "Top“ ; plot &var * fmonth = fyear / plot &var * fmonth = fyear / grid frame autovref grid frame autovref vaxis = axis1 vaxis = axis1 haxis = axis3 haxis = axis3 legend = legend1 legend = legend1 name = "RRTrks“ ; name = "RRTrks“ ; run; run;[snip] goptions display; goptions display; proc greplay nofs tc=mytcat igout=&mygout; proc greplay nofs tc=mytcat igout=&mygout; tdef mytemp tdef mytemp %panelDef( 1,0,100,0,100) %panelDef( 1,0,100,0,100) %panelDef( 2,0,100,&lowery1,&uppery1) %panelDef( 2,0,100,&lowery1,&uppery1) %panelDef( 3,0,100,&lowery2,&uppery2) ; %panelDef( 3,0,100,&lowery2,&uppery2) ; template mytemp; template mytemp; treplay treplay 1:titles 1:titles 2:Top 2:Top 3:RRTrks ; 3:RRTrks ; run; run;

Three Macros to Simplify Annotations

The SAS annotate facility give great flexibility in writing or drawing things on graphs – even producing specialized graphs The SAS annotate facility give great flexibility in writing or drawing things on graphs – even producing specialized graphs Typically, simple text is “dropped” onto a graph Typically, simple text is “dropped” onto a graph Learning annotate is not difficult but takes time Learning annotate is not difficult but takes time

Three simple macros can help Macro avars creates the basic variable needed in a dataset to annotate a graph Macro avars creates the basic variable needed in a dataset to annotate a graph Macro xyhsys specifies a “coordinate system” Macro xyhsys specifies a “coordinate system” Macro alabel defines a text label, placed anywhere you need it Macro alabel defines a text label, placed anywhere you need it

First an example The following code defines a “graph” that has the titles for a Multi-graph page: The following code defines a “graph” that has the titles for a Multi-graph page: data annotitles; data annotitles; %avars %avars %xyhsys( 1,1,1 ) %xyhsys( 1,1,1 ) %alabel( 50,100, "&title1",,,, 3.5, centb,E ) %alabel( 50,100, "&title1",,,, 3.5, centb,E ) %alabel( 50,95, "&title2",,,, 2.5, centb,E ) %alabel( 50,95, "&title2",,,, 2.5, centb,E ) run; run; proc ganno annotate=annotitles gout=&mygout name='titles'; proc ganno annotate=annotitles gout=&mygout name='titles'; run; run;

avars /*********************************************************** * Name: avars * * Desc: Annotate macro to declare and size standard * * annotate dataset variables * * Type: Graphics Utility - Annotate Macro * * Walt Smith May 10, 2001 * ***********************************************************/ %macro avars; length color function style $8; length color function style $8; length text $200; length text $200; length x y 8; length x y 8;%mend;

xyhsys /**************************************************************** * Name: xyhsys * * Desc: Annotate macro to set the value of three annotate * * variables: xsys, ysys, and hsys. * * Type: Graphics Utility - Annotate Macro * * * * ============================================= * * | Table of Coordinate System Codes | * * | (See SAS/Graph Software pg 476) | * * * * | Area | Units | Absolute | Relative | * * * * | Data | % | 1 | 7 | * * | Area | Values | 2 | 8 | * * * * | Graphics | % | 3 | 9 | * * | Output | Cells | 4 | A | * * | Area | | | | * * * * | Procedure | % | 5 | B | * * | Output | Cells | 6 | C | * * | Area | | | | * * ============================================= * ****************************************************************/ %macro xyhsys( xsys, ysys, hsys ); xsys = "&xsys"; xsys = "&xsys"; ysys = "&ysys"; ysys = "&ysys"; hsys = "&hsys"; hsys = "&hsys";%mend;

alabel /*********************************************************** * Name: alabel * * Desc: Annotate macro to place text on a graph * * Type: Graphics Utility - Annotate Macro * * * * Walt Smith November 30, 1999 * * 5/8/02 WJS Modify logic for pos parm * ***********************************************************/ %macro alabel (x,y,txt,coltxt,ang,rot,size,font,pos); %if ( %length( &x ) >0 ) %then x = &x %str(;); %if ( %length( &x ) >0 ) %then x = &x %str(;); %if ( %length( &y ) >0 ) %then y = &y %str(;); %if ( %length( &y ) >0 ) %then y = &y %str(;); %if ( %length( &ang ) >0 ) %then angle = &ang %str(;); %if ( %length( &ang ) >0 ) %then angle = &ang %str(;); %if ( %length( &rot ) >0 ) %then rotate = &rot %str(;); %if ( %length( &rot ) >0 ) %then rotate = &rot %str(;); %if ( %length( &size ) >0 ) %then size = &size%str(;); %if ( %length( &size ) >0 ) %then size = &size%str(;); %if ( %length( &txt ) >0 ) %then text = &txt %str(;); %if ( %length( &txt ) >0 ) %then text = &txt %str(;); %if ( %length( &font ) >0 ) %then style = "&font"%str(;); %if ( %length( &font ) >0 ) %then style = "&font"%str(;); %if ( %length( &pos ) =1 ) %then position = "&pos"%str(;); %if ( %length( &pos ) =1 ) %then position = "&pos"%str(;); %else %if ( %length( &pos ) > 1 ) %then position = &pos %str(;); %else %if ( %length( &pos ) > 1 ) %then position = &pos %str(;); %if %length(&coltxt)>0 %then color = "&coltxt"%str(;); %if %length(&coltxt)>0 %then color = "&coltxt"%str(;); function='label'; function='label'; output; output;%mend;

PROC SQL vs. PROC MEANS by John Ang Senior Merchandising Analyst AutoZone

Summary Functions in PROC SQL The following summary functions are available when using PROC SQL: AVG COUNT MIN MAX STD SUM VAR The GROUP BY statement is used in conjunction with these summary functions.

PROC SQL Query proc sql; create table boo as select hoo, sum(foo) as goo from doo group by hoo; quit;

Output Statistics in PROC MEANS The following output statistics are available when using PROC SQL: MEAN N MIN MAX STD SUM VAR The OUTPUT statement is used in conjunction with these output statistics.

PROC MEANS Query proc means data=doo sum mean noprint; class hoo; var foo; output out=boo sum=goo; run;

Comparison of SAS Log 135 proc sql; 136 create table boo as 137 select hoo, sum(foo) as goo 138 from doo 139 group by hoo; NOTE: Table WORK.BOO created, with rows and 2 columns. 140 quit; NOTE: PROCEDURE SQL used: real time 1:15.31 cpu time seconds 141 proc means data=doo sum mean noprint; 142 class hoo; 143 var foo; 144 output out=boo2 sum=goo; 145 run; NOTE: There were observations read from the data set DAD5DATA.SSPOLK. NOTE: The data set WORK.BOO2 has observations and 2 variables. NOTE: PROCEDURE MEANS used: real time seconds cpu time seconds

Another Example proc means data=limahl.omd sum noprint; class time; var edge; output out=sting1 sum=toto; run; proc sql; create table sting2 as select time, sum(edge) as toto from limahl.omd group by time; quit;

Another SAS Log 3 proc means data=limahl.omd sum noprint; 4 class time; 5 var edge; 6 output out=sting1 sum=toto; 7 run; NOTE: There were observations read from the data set SREGDATA.VITEMADJ_DOWNLOAD. NOTE: The data set WORK.STING1 has observations and 4 variables. NOTE: PROCEDURE MEANS used: real time 23:16.58 cpu time 12: proc sql; 10 create table sting2 as 11 select time, sum(edge) as toto 12 from limahl.omd 13 group by time; NOTE: Table WORK.STING2 created, with rows and 2 columns. 14 quit; NOTE: PROCEDURE SQL used: real time 50:50.62 cpu time 23:33.05

PROC SQL or PROC MEANS? PROC SQL code can be more readable and easily understood by other SAS users. Generally, PROC MEANS will produce the same summarized result in less CPU time than PROC SQL will. More descriptive statistics (e.g. quantiles) are available with PROC MEANS than with PROC SQL.