Planting Your Rows: Using SAS Formats to Make the Generation of Zero- Filled Rows in Tables Less Thorny
|
|
- Geoffrey Anthony
- 5 years ago
- Views:
Transcription
1 Planting Your Rows: Using SAS Formats to Make the Generation of Zero- Filled Rows in Tables Less Thorny Kathy Hardis Fraeman, United BioSource Corporation, Bethesda, MD ABSTRACT Often tables or summary reports need to be produced with SAS where all possible values of one or more variables need to be included as rows in a table. However, the actual data to be summarized in a table might include variables that don t have all of the variables possible values, even though the table needs a corresponding zero-filled row for that variable value. These zero-filled table rows for non-existent variable values will be missing from the table unless additional programming is done. One programming method to make sure all rows are included would be to hard code all possible values of a variable, although this method could be tedious if a large number of variables and/or values are involved. A more dynamic method of determining all possible values of a variable is to attach a SAS format to each table variable, where the format contains all of the variable s possible values. SAS can dynamically determine the name of a format attached to a variable using SYSFUNC with SCL or a dictionary table using PROC SQL. SAS can then generate a data set of all possible values for the variable by using the CNTLOUT = <dataset> option of. The output data set generated from can be dynamically used to ensure that all possible values of a variable, even values that don t actually exist in the data, will be included as rows in a table. INTRODUCTION Tables or summary reports may need to be produced using SAS where all possible values of one or more variables must be included as rows in the tables. However, the actual input data to be summarized in such a table might include not include all possible combinations of data values of all relevant variables. If the table needs rows for all possible combinations of these data values, zero-filled table rows for these non-existent variable values will be missing from the table unless additional programming is done. One programming method to make sure all rows are included would be to hard code all possible values and combinations of values of a variable or variables. This method has the disadvantage of potentially being tedious if a large number of variables and/or values are involved, and not dynamic if the possible values of a variable will change over time. A more dynamic method of determining all possible values of a variable is to attach a SAS format to each variable, where the format contains all of the variable s possible values. This paper will show how determine the format attached to a variable, how to determine the data values defined in the format, and then how to use this information to create a table that will include rows for all possible data values as defined by the format. SAMPLE DATA The sample data in the SAS data set IN.SALES used in this paper are given below: Obs employee year num dollar 1 Hall FY $10, Hall FY $15, Oates FY $ Brooks FY $11, Brooks FY $12, Abbot FY $75, Abbot FY $99, Costello FY $33, Costello FY $44,444.44
2 Both employee and year are numeric variables with attached formats. The formats used for those variables are given as: proc format library = library; value emplfmt 1 = "Hall" 2 = "Oates" 3 = "Brooks" 4 = "Dunn" 5 = "Abbot" 6 = "Costello" ; value yearfmt 2008 = "FY 2008" 2009 = "FY 2009" 2010 = "FY 2010" ; The format EMPLFMT is attached to the variable EMPLOYEE, and format YEARFMT is attached to the variable YEAR. These formats include all possible values for the variables and can be updated when new possible data values are added. REPORT WITH MISSING ROWS A report is needed using the sample data that gives the number of sales and the dollar amount of sales for each fiscal year and by employee within year. The PROC REPORT code to produce such a table is: title "Report with Missing Rows"; proc report data=in.sales nowindows headline headskip; column year employee num dollar; define year / group 'Year' order=data; define employee / display 'Employee' order = data; define num / display 'Number of sales'; define dollar / display 'Amount of sales'; break after year / skip; The report with the original data looks like:
3 Report with Missing Rows Number Amount of Year Employee of sales sales ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ FY 2008 Hall 10 $10, Oates 8 $ Brooks 15 $11, Abbot 50 $75, Costello 33 $33, FY 2010 Hall 15 $15, Brooks 20 $12, Abbot 75 $99, Costello 44 $44, The above table has missing rows for combinations of the variables year and employee were no data were available. No data were available at all for the year 2009, and not all employees had sales data for both 2008 and If the table needs to have rows for all possible combinations of year and employee even if no data exists for those combinations values of the variables attached formats can be used to determine all possible combination of data values. DETERMINING A VARIABLE S FORMAT SAS can dynamically determine the name of a format attached to a variable with either of two different techniques: %SYSFUNC with SCL a dictionary table using PROC SQL Each method will be discussed separately below. METHOD 1 -- %SYSFUNC WITH SAS SCREEN CONTROL LANGUAGE %SYSFUNC was originally developed in SAS version 6.12 to allow the incorporation of SCL (SAS Component Language, formerly Screen Control Language) functions into the SAS macro programming environment. Among its many capabilities, %SYSFUNC can determine the existence of a SAS data set and characterize the attributes of the data set s variables, such as the variable s format. The SCL code to determine a variable s format and put the name of the format in a macro variable is: %let dsid = %sysfunc(open(in.sales, i)); %let varnum = %sysfunc(varnum(&dsid, EMPLOYEE)); %let format = %sysfunc(varfmt(&dsid, &varnum)); %let rc = %sysfunc(close(&dsid)); %put EMPLOYEE VARIABLE FORMAT = &format;
4 IN.SALES is the name of the data set, and EMPLOYEE is the name of the variable in the data set IN.SALES. The name of the format attached to EMPLOYEE is EMPLFMT., and the value of the macro variable &format will be displayed in the SAS log as: 999 %put EMPLOYEE VARIABLE FORMAT = &format; EMPLOYEE VARIABLE FORMAT = EMPLFMT. Note that the. in the format name is included in the value of the macro variable. METHOD 2 -- PROC SQL DICTIONARY TABLES Structured Query Language (SQL) is a standard and widely used language and has been implemented in SAS as PROC SQL. Dictionary tables provide metadata about SAS data sets and variables, and they can be generated at runtime by using PROC SQL The PROC SQL code to determine a variable s format using a dictionary table is given below: proc sql; create table formats as select format from dictionary.columns where upcase(libname) = 'IN' and upcase(memname) = 'SALES' and upcase(name) = ('EMPLOYEE') ; quit; proc print data=formats; The PROC PRINT of the data set FORMATS will look like: Obs format 1 EMPLFMT. Again, note that the. in the format name is included in the value of the variable. DETERMINING ALL VALUES IN A FORMAT USING THE CNTLOUT OPTION OF A SAS format library is stored in SAS as a catalog, and the values of a user-defined SAS format library can be put into a SAS data set using the CNTLOUT option of. This SAS format data set created with the CNTLOUT option contains multiple variables relevant to the format library, but the three variables in the CNTLOUT data set relevant to this analysis are: FMTNAME name of the format START starting value of the format LABEL descriptive label associated with the value of START
5 The SAS code to use the CNTLOUT= option with to put the format information in a SAS data set named FORMATLIB is given below: proc format library=library cntlout = formatlib (keep = fmtname start label); proc print data=formatlib; The PROC PRINT of the data set FORMATLIB will look like: Obs FMTNAME START LABEL 1 EMPLFMT 1 Hall 2 EMPLFMT 2 Oates 3 EMPLFMT 3 Brooks 4 EMPLFMT 4 Dunn 5 EMPLFMT 5 Abbot 6 EMPLFMT 6 Costello 7 YEARFMT 2008 FY YEARFMT 2009 FY YEARFMT 2010 FY 2010 For the CNTLOUT data created by note that the. in the format name is not included in the value of the variable FMTNAME, although the. is included in the format names generated by both the %SYSFUNC and SQL dictionary table methods shown above. Format names generated by the CNTLOUT = option of need to have a. appended to the end of the format name to be compared to the format other formats. A. can be appended using the CATS function shown below. fmtname = cats(fmtname,. ); USING ALL VALUES OF AN ATTACHED FORMAT TO FILL IN MISSING TABLE ROWS The two SAS programming techniques described above can be combined to be determine all possible combinations of a single variable, or as in this paper, combinations of two variables METHOD 1 -- %SYSFUNC WITH SAS SCREEN CONTROL LANGUAGE AND CNTLOUT %SYSFUNC and the CNTLOUT= option of can be combined in the following macro to determine the name of a format associated with a variable &VAR and put all of the format s defined values in an output data set &OUTVALS:
6 /************************************************/ /* OPTION 1: /* Get values of formats using %SYSFUNC and SCL /* Note that input data set name IN.SALES is /* coded in the macro /*************************************************/ %macro getfmt1(var=, outvals=); %let dsid %let varnum %let varfmt %let rc = %sysfunc(open(in.sales,i)); = %sysfunc(varnum(&dsid, &var)); = %sysfunc(varfmt(&dsid, &varnum)); = %sysfunc(close(&dsid)); %put &varfmt; proc format library = library cntlout = &outvals (keep = fmtname start label where = (cats(fmtname,'.') = "&varfmt")); title "Data set &outvals from macro GETFMT1 -- SYSFUNC and SCL"; proc print data = &outvals; %mend getfmt1; %getfmt1(var=employee, outvals=empvals); %getfmt1(var=year, outvals=yearvals); Note that the input data set IN.SALES is hardcoded in the example of the macro given above. The two output data sets created by the above macro look like: Data set empvals from macro GETFMT1 -- SYSFUNC and SCL Obs FMTNAME START LABEL 1 EMPLFMT 1 Hall 2 EMPLFMT 2 Oates 3 EMPLFMT 3 Brooks 4 EMPLFMT 4 Dunn 5 EMPLFMT 5 Abbot 6 EMPLFMT 6 Costello
7 Data set yearvals from macro GETFMT1 -- SYSFUNC and SCL Obs FMTNAME START LABEL 1 YEARFMT 2008 FY YEARFMT 2009 FY YEARFMT 2010 FY 2010 METHOD 2 -- PROC SQL DICTIONARY TABLES AND CNTLOUT PROC SQL dictionary tables and the CNTLOUT= option of can also be combined in the following macro to determine the name of a format associated with a variable &VAR and put all of the format s defined values in an output data set &OUTVALS: /******************************************************************/ /* OPTION 2: /* Get values of formats using SQL Dictionary Table /* Note that input data set name IN.SALES is coded in the macro /*****************************************************************/ %macro getfmt2(var=, outvals=); proc sql; create table &var.fmt as select format from dictionary.columns where upcase(libname) = 'IN' and upcase(memname) = 'SALES' and upcase(name) = upcase("&var") ; quit; /*****************************************************/ /* Turn the name of the format into a macro variable /*****************************************************/ data _null_; set &var.fmt; call symputx("varfmt", format, 'L'); %put &varfmt;
8 proc format library=library cntlout = &outvals (keep = fmtname start label where = (cats(fmtname,'.') = "&varfmt")); title "Data set &outvals from macro GETFMT2 -- SQL Dictionary Table"; proc print data = &outvals; %mend getfmt2; %getfmt2(var=employee, outvals=empvals); %getfmt2(var=year, outvals=yearvals); The output data from this macro GETFMT2 is given below and looks exactly the same as the output for the macro GETFMT1. Data set empvals from macro GETFMT2 -- SQL Dictionary Table Obs FMTNAME START LABEL 1 EMPLFMT 1 Hall 2 EMPLFMT 2 Oates 3 EMPLFMT 3 Brooks 4 EMPLFMT 4 Dunn 5 EMPLFMT 5 Abbot 6 EMPLFMT 6 Costello Data set yearvals from macro GETFMT2 -- SQL Dictionary Table Obs FMTNAME START LABEL 1 YEARFMT 2008 FY YEARFMT 2009 FY YEARFMT 2010 FY 2010 CREATE A DATA SET WITH ALL POSSIBLE VALUES OF BOTH VARIABLES, BASED ON ATTACHED FORMATS The following SAS code shows how to create a SAS data set with all possible values of the variables YEAR and EMPLOYEE, using the format values from the variables attached formats.
9 /********************************************************************/ /* Create SAS data sets of all possible values of YEAR and EMPLOYEE /********************************************************************/ data yearvals_mod (keep = year a); set yearvals; /* */ /* Convert character variable START to numeric /* */ year = input(trim(left(start)),8.); /* */ /* Dummy variable for SQL join /* */ a = 1; data empvals_mod (keep = employee b); set empvals; /* */ /* Convert character variable START to numeric /* */ employee = input(trim(left(start)),8.); /* */ /* Dummy variable for SQL join /* */ b = 1; /****************************************************************************/ /* Create a SAS data set of all possible combinations of YEAR and EMPLOYEE /* using all possible values of YEAR and EMPLOYEE /****************************************************************************/ proc sql; create table allrows as select year, employee from yearvals_mod y, empvals_mod e where y.a = e.b; quit; proc sort data=allrows; by year employee; The data set ALLROWS will look like this:
10 All rows needed for table Obs year employee Formats will be attached to the variables after the merge with the actual data. CREATE A DATA SET WITH ZERO-FILLED VALUES WHEN DATA ARE MISSING The data set created above can be merged with the input data to the table program IN.SALES to create zero-filled rows as follows: proc sort data=in.sales out=sales; by year employee; data sales_all; merge allrows (in=a) sales (in=s); by year employee; /* */ /* Zero-fill the missing rows /* */ if a and ^s then do; num = 0; dollar = 0; end;
11 When the data set SALES_ALL is used as input to the PROC REPORT program, the table will have zero-filled rows for values of the variables that don t occur in the data. Report without Missing Rows Number Amount of Year Employee of sales sales ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ FY 2008 Hall 10 $10, Oates 8 $ Brooks 15 $11, Dunn 0 $0.00 Abbot 50 $75, Costello 33 $33, FY 2009 Hall 0 $0.00 Oates 0 $0.00 Brooks 0 $0.00 Dunn 0 $0.00 Abbot 0 $0.00 Costello 0 $0.00 FY 2010 Hall 15 $15, Oates 0 $0.00 Brooks 20 $12, Dunn 0 $0.00 Abbot 75 $99, Costello 44 $44, CONCLUSION This SAS programming techniques using SAS formats included in this paper demonstrate just a few of the many wonderful ways that SAS formats can be used to improve the SAS programming process. ACKNOWLEDGMENTS SAS is a Registered Trademark of the SAS Institute, Inc. of Cary, North Carolina. CONTACT INFORMATION Please contact the author with any comments, questions, or gardening tips: Kathy H. Fraeman United BioSource Corporation 7101 Wisconsin Avenue, Suite 600 Bethesda, MD (240) voice (301) fax kathy.fraeman@unitedbiosource.com
Get into the Groove with %SYSFUNC: Generalizing SAS Macros with Conditionally Executed Code
Get into the Groove with %SYSFUNC: Generalizing SAS Macros with Conditionally Executed Code Kathy Hardis Fraeman, United BioSource Corporation, Bethesda, MD ABSTRACT %SYSFUNC was originally developed in
More informationLet SAS Write and Execute Your Data-Driven SAS Code
Let SAS Write and Execute Your Data-Driven SAS Code Kathy Hardis Fraeman, United BioSource Corporation, Bethesda, MD ABSTRACT Some SAS programming statements are based on specific values of data, such
More informationSTEP 1 - /*******************************/ /* Manipulate the data files */ /*******************************/ <<SAS DATA statements>>
Generalized Report Programming Techniques Using Data-Driven SAS Code Kathy Hardis Fraeman, A.K. Analytic Programming, L.L.C., Olney, MD Karen G. Malley, Malley Research Programming, Inc., Rockville, MD
More informationValidation Summary using SYSINFO
Validation Summary using SYSINFO Srinivas Vanam Mahipal Vanam Shravani Vanam Percept Pharma Services, Bridgewater, NJ ABSTRACT This paper presents a macro that produces a Validation Summary using SYSINFO
More informationBetter Metadata Through SAS II: %SYSFUNC, PROC DATASETS, and Dictionary Tables
Paper 3458-2015 Better Metadata Through SAS II: %SYSFUNC, PROC DATASETS, and Dictionary Tables ABSTRACT Louise Hadden, Abt Associates Inc., Cambridge, MA SAS provides a wealth of resources for users to
More informationConversion of CDISC specifications to CDISC data specifications driven SAS programming for CDISC data mapping
PharmaSUG 2017 - Paper DA03 Conversion of CDISC specifications to CDISC data specifications driven SAS programming for CDISC data mapping Yurong Dai, Jiangang Jameson Cai, Eli Lilly and Company ABSTRACT
More informationCommon Sense Tips and Clever Tricks for Programming with Extremely Large SAS Data Sets
Common Sense Tips and Clever Tricks for Programming with Extremely Large SAS Data Sets Kathy Hardis Fraeman, United BioSource Corporation, Bethesda, MD ABSTRACT Working with extremely large SAS data sets
More informationfootnote1 height=8pt j=l "(Rev. &sysdate)" j=c "{\b\ Page}{\field{\*\fldinst {\b\i PAGE}}}";
Producing an Automated Data Dictionary as an RTF File (or a Topic to Bring Up at a Party If You Want to Be Left Alone) Cyndi Williamson, SRI International, Menlo Park, CA ABSTRACT Data dictionaries are
More informationGive me EVERYTHING! A macro to combine the CONTENTS procedure output and formats. Lynn Mullins, PPD, Cincinnati, Ohio
PharmaSUG 2014 - Paper CC43 Give me EVERYTHING! A macro to combine the CONTENTS procedure output and formats. Lynn Mullins, PPD, Cincinnati, Ohio ABSTRACT The PROC CONTENTS output displays SAS data set
More informationABSTRACT. Paper CC-031
Paper CC-031 Using Functions SYSFUNC and IFC to Conditionally Execute Statements in Open Code Ronald J. Fehd, Centers for Disease Control and Prevention, Atlanta, GA, USA ABSTRACT Audience Keywords Information
More informationMOBILE MACROS GET UP TO SPEED SOMEWHERE NEW FAST Author: Patricia Hettinger, Data Analyst Consultant Oakbrook Terrace, IL
MOBILE MACROS GET UP TO SPEED SOMEWHERE NEW FAST Author: Patricia Hettinger, Data Analyst Consultant Oakbrook Terrace, IL ABSTRACT: Have you ever been faced with this scenario? It s your first day on the
More informationUncommon Techniques for Common Variables
Paper 11863-2016 Uncommon Techniques for Common Variables Christopher J. Bost, MDRC, New York, NY ABSTRACT If a variable occurs in more than one data set being merged, the last value (from the variable
More informationDictionary.coumns is your friend while appending or moving data
ABSTRACT SESUG Paper CC-41-2017 Dictionary.coumns is your friend while appending or moving data Kiran Venna, Dataspace Inc. Dictionary.columns is a dictionary table, which gives metadata information of
More information10 The First Steps 4 Chapter 2
9 CHAPTER 2 Examples The First Steps 10 Invoking the Query Window 11 Changing Your Profile 11 ing a Table 13 ing Columns 14 Alias Names and Labels 14 Column Format 16 Creating a WHERE Expression 17 Available
More informationCalculating Cardinality Ratio in Two Steps
MWSUG 2016 Paper TT03 Calculating Cardinality Ratio in Two Steps Ronald J. Fehd, Stakana Analytics Abstract Description: Purpose: Audience: Keywords: The cardinality of a set is the number of elements
More informationAn Efficient Method to Create Titles for Multiple Clinical Reports Using Proc Format within A Do Loop Youying Yu, PharmaNet/i3, West Chester, Ohio
PharmaSUG 2012 - Paper CC12 An Efficient Method to Create Titles for Multiple Clinical Reports Using Proc Format within A Do Loop Youying Yu, PharmaNet/i3, West Chester, Ohio ABSTRACT Do you know how to
More informationA Format to Make the _TYPE_ Field of PROC MEANS Easier to Interpret Matt Pettis, Thomson West, Eagan, MN
Paper 045-29 A Format to Make the _TYPE_ Field of PROC MEANS Easier to Interpret Matt Pettis, Thomson West, Eagan, MN ABSTRACT: PROC MEANS analyzes datasets according to the variables listed in its Class
More informationMerge Processing and Alternate Table Lookup Techniques Prepared by
Merge Processing and Alternate Table Lookup Techniques Prepared by The syntax for data step merging is as follows: International SAS Training and Consulting This assumes that the incoming data sets are
More informationINTRODUCTION TO SAS HOW SAS WORKS READING RAW DATA INTO SAS
TO SAS NEED FOR SAS WHO USES SAS WHAT IS SAS? OVERVIEW OF BASE SAS SOFTWARE DATA MANAGEMENT FACILITY STRUCTURE OF SAS DATASET SAS PROGRAM PROGRAMMING LANGUAGE ELEMENTS OF THE SAS LANGUAGE RULES FOR SAS
More informationKnow Thy Data : Techniques for Data Exploration
Know Thy Data : Techniques for Data Exploration Montreal SAS Users Group Wednesday, 29 May 2018 13:50-14:30 PM Andrew T. Kuligowski, Charu Shankar AGENDA Part 1- Easy Ways to know your data Part 2 - Powerful
More informationQuick Data Definitions Using SQL, REPORT and PRINT Procedures Bradford J. Danner, PharmaNet/i3, Tennessee
ABSTRACT PharmaSUG2012 Paper CC14 Quick Data Definitions Using SQL, REPORT and PRINT Procedures Bradford J. Danner, PharmaNet/i3, Tennessee Prior to undertaking analysis of clinical trial data, in addition
More information1 Files to download. 3 Macro to list the highest and lowest N data values. 2 Reading in the example data file
1 2 22S:172 Lab session 10 Macros for data cleaning July 17, 2003 GENDER VISIT HR SBP DBP DX AE = "Gender" = "Visit Date" = "Heart Rate" = "Systolic Blood Pressure" = "Diastolic Blood Pressure" = "Diagnosis
More informationPharmaSUG China. Systematically Reordering Axis Major Tick Values in SAS Graph Brian Shen, PPDI, ShangHai
PharmaSUG China Systematically Reordering Axis Major Tick Values in SAS Graph Brian Shen, PPDI, ShangHai ABSTRACT Once generating SAS graphs, it is a headache to programmers to reorder the axis tick values
More informationQuick and Efficient Way to Check the Transferred Data Divyaja Padamati, Eliassen Group Inc., North Carolina.
ABSTRACT PharmaSUG 2016 - Paper QT03 Quick and Efficient Way to Check the Transferred Data Divyaja Padamati, Eliassen Group Inc., North Carolina. Consistency, quality and timelines are the three milestones
More informationDocument and Enhance Your SAS Code, Data Sets, and Catalogs with SAS Functions, Macros, and SAS Metadata. Louise S. Hadden. Abt Associates Inc.
Document and Enhance Your SAS Code, Data Sets, and Catalogs with SAS Functions, Macros, and SAS Metadata Louise S. Hadden Abt Associates Inc. Louise Hadden has been using and loving SAS since the days
More informationTaming a Spreadsheet Importation Monster
SESUG 2013 Paper BtB-10 Taming a Spreadsheet Importation Monster Nat Wooding, J. Sargeant Reynolds Community College ABSTRACT As many programmers have learned to their chagrin, it can be easy to read Excel
More informationWHAT ARE SASHELP VIEWS?
Paper PN13 There and Back Again: Navigating between a SASHELP View and the Real World Anita Rocha, Center for Studies in Demography and Ecology University of Washington, Seattle, WA ABSTRACT A real strength
More informationCreate Metadata Documentation using ExcelXP
Paper AD13 Create Metadata Documentation using ExcelXP Christine Teng, Merck Research Labs, Merck & Co., Inc., Rahway, NJ ABSTRACT The purpose of the metadata documentation is two-fold. First, it facilitates
More informationBreakOnWord: A Macro for Partitioning Long Text Strings at Natural Breaks Richard Addy, Rho, Chapel Hill, NC Charity Quick, Rho, Chapel Hill, NC
PharmaSUG 2014 - Paper CC20 BreakOnWord: A Macro for Partitioning Long Text Strings at Natural Breaks Richard Addy, Rho, Chapel Hill, NC Charity Quick, Rho, Chapel Hill, NC ABSTRACT Breaking long text
More informationPaper B GENERATING A DATASET COMPRISED OF CUSTOM FORMAT DETAILS
Paper B07-2009 Eliminating Redundant Custom Formats (or How to Really Take Advantage of Proc SQL, Proc Catalog, and the Data Step) Philip A. Wright, University of Michigan, Ann Arbor, MI ABSTRACT Custom
More informationSAS File Management. Improving Performance CHAPTER 37
519 CHAPTER 37 SAS File Management Improving Performance 519 Moving SAS Files Between Operating Environments 520 Converting SAS Files 520 Repairing Damaged Files 520 Recovering SAS Data Files 521 Recovering
More informationVirtual Accessing of a SAS Data Set Using OPEN, FETCH, and CLOSE Functions with %SYSFUNC and %DO Loops
Paper 8140-2016 Virtual Accessing of a SAS Data Set Using OPEN, FETCH, and CLOSE Functions with %SYSFUNC and %DO Loops Amarnath Vijayarangan, Emmes Services Pvt Ltd, India ABSTRACT One of the truths about
More informationUsing SAS/SCL to Create Flexible Programs... A Super-Sized Macro Ellen Michaliszyn, College of American Pathologists, Northfield, IL
Using SAS/SCL to Create Flexible Programs... A Super-Sized Macro Ellen Michaliszyn, College of American Pathologists, Northfield, IL ABSTRACT SAS is a powerful programming language. When you find yourself
More informationSQL Metadata Applications: I Hate Typing
SQL Metadata Applications: I Hate Typing Hannah Fresques, MDRC, New York, NY ABSTRACT This paper covers basics of metadata in SQL and provides useful applications, including: finding variables on one or
More informationWhy choose between SAS Data Step and PROC SQL when you can have both?
Paper QT-09 Why choose between SAS Data Step and PROC SQL when you can have both? Charu Shankar, SAS Canada ABSTRACT As a SAS coder, you've often wondered what the SQL buzz is about. Or vice versa you
More informationChapter 6: Modifying and Combining Data Sets
Chapter 6: Modifying and Combining Data Sets The SET statement is a powerful statement in the DATA step. Its main use is to read in a previously created SAS data set which can be modified and saved as
More informationContents of SAS Programming Techniques
Contents of SAS Programming Techniques Chapter 1 About SAS 1.1 Introduction 1.1.1 SAS modules 1.1.2 SAS module classification 1.1.3 SAS features 1.1.4 Three levels of SAS techniques 1.1.5 Chapter goal
More informationEfficient Processing of Long Lists of Variable Names
Efficient Processing of Long Lists of Variable Names Paulette W. Staum, Paul Waldron Consulting, West Nyack, NY ABSTRACT Many programmers use SAS macro language to manipulate lists of variable names. They
More information. NO MORE MERGE - Alternative Table Lookup Techniques Dana Rafiee, Destiny Corporation/DDISC Group Ltd. U.S., Wethersfield, CT
betfomilw tltlljri4ls. NO MORE MERGE - Alternative Table Lookup Techniques Dana Rafiee, Destiny Corporation/DDISC Group Ltd. U.S., Wethersfield, CT ABSTRACT This tutorial is designed to show you several
More informationwork.test temp.test sasuser.test test
DSCI 325 Midterm Practice Test Spring 2017 Name: 1. Consider the following four names used to create a SAS data set: work.test temp.test sasuser.test test How many of these will be stored as permanent
More informationMake Your Life a Little Easier: A Collection of SAS Macro Utilities. Pete Lund, Northwest Crime and Social Research, Olympia, WA
Make Your Life a Little Easier: A Collection of SAS Macro Utilities Pete Lund, Northwest Crime and Social Research, Olympia, WA ABSTRACT SAS Macros are used in a variety of ways: to automate the generation
More informationExploring DICTIONARY Tables and SASHELP Views
Exploring DICTIONARY Tables and SASHELP Views Kirk Paul Lafler, Software Intelligence Corporation Abstract SAS users can quickly and conveniently obtain useful information about their SAS session with
More informationSAS Certification Handout #10: Adv. Prog. Ch. 5-8
SAS Certification Handout #10: Adv. Prog. Ch. 5-8 /************ Ch. 5 ******************* /* First, make example data -- same as Handout #9 libname cert 'C:/jrstevens/Teaching/SAS_Cert/AdvNotes'; /* In
More informationA SAS Macro to Create Validation Summary of Dataset Report
ABSTRACT PharmaSUG 2018 Paper EP-25 A SAS Macro to Create Validation Summary of Dataset Report Zemin Zeng, Sanofi, Bridgewater, NJ This paper will introduce a short SAS macro developed at work to create
More informationHow to Create Data-Driven Lists
Paper 9540-2016 How to Create Data-Driven Lists Kate Burnett-Isaacs, Statistics Canada ABSTRACT As SAS programmers we often want our code or program logic to be driven by the data at hand, rather than
More informationTop 5 Handy PROC SQL Tips You Didn t Think Were Possible
Top 5 Handy PROC SQL Tips You Didn t Think Were Possible Montreal SAS users Group 30 May 2018 11:00-11:40 Charu Shankar SAS Institute, Toronto About your presenter SAS Senior Technical Training Specialist,
More informationPaper PO06. Building Dynamic Informats and Formats
Paper PO06 Building Dynamic Informats and Formats Michael Zhang, Merck & Co, Inc, West Point, PA ABSTRACT Using the FORMAT procedure to define informats and formats is a common task in SAS programming
More informationAn SQL Tutorial Some Random Tips
An SQL Tutorial Some Random Tips Presented by Jens Dahl Mikkelsen SAS Institute A/S Author: Paul Kent SAS Institute Inc, Cary, NC. Short Stories Towards a Better UNION Outer Joins. More than two too. Logical
More informationSAS coding for those who like to be control
SAS coding for those who like to be control Montreal SAS Users Group 30 May 2018 Charu Shankar SAS Institute, Toronto About your presenter SAS Senior Technical Training Specialist, Charu Shankar teaches
More informationBASICS BEFORE STARTING SAS DATAWAREHOSING Concepts What is ETL ETL Concepts What is OLAP SAS. What is SAS History of SAS Modules available SAS
SAS COURSE CONTENT Course Duration - 40hrs BASICS BEFORE STARTING SAS DATAWAREHOSING Concepts What is ETL ETL Concepts What is OLAP SAS What is SAS History of SAS Modules available SAS GETTING STARTED
More informationTop-Down Programming with SAS Macros Edward Heaton, Westat, Rockville, MD
Paper P813 Top-Down Programming with SAS Macros Edward Heaton, Westat, Rockville, MD ABSTRACT Structured, top-down programming techniques are not intuitively obvious in the SAS language, but macros can
More informationA Simple Framework for Sequentially Processing Hierarchical Data Sets for Large Surveys
A Simple Framework for Sequentially Processing Hierarchical Data Sets for Large Surveys Richard L. Downs, Jr. and Pura A. Peréz U.S. Bureau of the Census, Washington, D.C. ABSTRACT This paper explains
More informationExtending the Scope of Custom Transformations
Paper 3306-2015 Extending the Scope of Custom Transformations Emre G. SARICICEK, The University of North Carolina at Chapel Hill. ABSTRACT Building and maintaining a data warehouse can require complex
More informationBuilding Intelligent Macros: Using Metadata Functions with the SAS Macro Language Arthur L. Carpenter California Occidental Consultants, Anchorage, AK
Paper 835-2017 Building Intelligent Macros: Using Metadata Functions with the SAS Macro Language Arthur L. Carpenter California Occidental Consultants, Anchorage, AK ABSTRACT The SAS macro language gives
More informationUsing Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse
Paper DM-01 Using Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse Abstract Ben Cochran, The Bedford Group, Raleigh, NC Often SAS users need to access
More informationGuide Users along Information Pathways and Surf through the Data
Guide Users along Information Pathways and Surf through the Data Stephen Overton, Overton Technologies, LLC, Raleigh, NC ABSTRACT Business information can be consumed many ways using the SAS Enterprise
More informationReducing SAS Dataset Merges with Data Driven Formats
Paper CT01 Reducing SAS Dataset Merges with Data Driven Formats Paul Grimsey, Roche Products Ltd, Welwyn Garden City, UK ABSTRACT Merging different data sources is necessary in the creation of analysis
More informationNO MORE MERGE. Alternative Table Lookup Techniques
NO MORE MERGE. Alternative Table Lookup Techniques Dana Rafiee, Destiny Corporation/DDISC Group Ltd. U.S., Wethersfield, CT ABSTRACT This tutorial is designed to show you several techniques available for
More information%Addval: A SAS Macro Which Completes the Cartesian Product of Dataset Observations for All Values of a Selected Set of Variables
%Addval: A SAS Macro Which Completes the Cartesian Product of Dataset Observations for All Values of a Selected Set of Variables Rich Schiefelbein, PRA International, Lenexa, KS ABSTRACT It is often useful
More informationSample Questions. SAS Advanced Programming for SAS 9. Question 1. Question 2
Sample Questions The following sample questions are not inclusive and do not necessarily represent all of the types of questions that comprise the exams. The questions are not designed to assess an individual's
More informationThe SERVER Procedure. Introduction. Syntax CHAPTER 8
95 CHAPTER 8 The SERVER Procedure Introduction 95 Syntax 95 Syntax Descriptions 96 Examples 101 ALLOCATE SASFILE Command 101 Syntax 101 Introduction You invoke the SERVER procedure to start a SAS/SHARE
More informationMerging Data Eight Different Ways
Paper 197-2009 Merging Data Eight Different Ways David Franklin, Independent Consultant, New Hampshire, USA ABSTRACT Merging data is a fundamental function carried out when manipulating data to bring it
More informationTop 10 Ways to Optimize Your SAS Code Jeff Simpson SAS Customer Loyalty
Top 10 Ways to Optimize Your SAS Code Jeff Simpson SAS Customer Loyalty Writing efficient SAS programs means balancing the constraints of TIME Writing efficient SAS programs means balancing Time and SPACE
More informationDeveloping Data-Driven SAS Programs Using Proc Contents
Developing Data-Driven SAS Programs Using Proc Contents Robert W. Graebner, Quintiles, Inc., Kansas City, MO ABSTRACT It is often desirable to write SAS programs that adapt to different data set structures
More informationBase and Advance SAS
Base and Advance SAS BASE SAS INTRODUCTION An Overview of the SAS System SAS Tasks Output produced by the SAS System SAS Tools (SAS Program - Data step and Proc step) A sample SAS program Exploring SAS
More informationPaper An Automated Reporting Macro to Create Cell Index An Enhanced Revisit. Shi-Tao Yeh, GlaxoSmithKline, King of Prussia, PA
ABSTRACT Paper 236-28 An Automated Reporting Macro to Create Cell Index An Enhanced Revisit When generating tables from SAS PROC TABULATE or PROC REPORT to summarize data, sometimes it is necessary to
More informationSAS 101. Based on Learning SAS by Example: A Programmer s Guide Chapter 21, 22, & 23. By Tasha Chapman, Oregon Health Authority
SAS 101 Based on Learning SAS by Example: A Programmer s Guide Chapter 21, 22, & 23 By Tasha Chapman, Oregon Health Authority Topics covered All the leftovers! Infile options Missover LRECL=/Pad/Truncover
More informationTop Coding Tips. Neil Merchant Technical Specialist - SAS
Top Coding Tips Neil Merchant Technical Specialist - SAS Bio Work in the ANSWERS team at SAS o Analytics as a Service and Visual Analytics Try before you buy SAS user for 12 years obase SAS and O/S integration
More informationIdentifying Duplicate Variables in a SAS Data Set
Paper 1654-2018 Identifying Duplicate Variables in a SAS Data Set Bruce Gilsen, Federal Reserve Board, Washington, DC ABSTRACT In the big data era, removing duplicate data from a data set can reduce disk
More informationDBLOAD Procedure Reference
131 CHAPTER 10 DBLOAD Procedure Reference Introduction 131 Naming Limits in the DBLOAD Procedure 131 Case Sensitivity in the DBLOAD Procedure 132 DBLOAD Procedure 132 133 PROC DBLOAD Statement Options
More informationCleaning Duplicate Observations on a Chessboard of Missing Values Mayrita Vitvitska, ClinOps, LLC, San Francisco, CA
Cleaning Duplicate Observations on a Chessboard of Missing Values Mayrita Vitvitska, ClinOps, LLC, San Francisco, CA ABSTRACT Removing duplicate observations from a data set is not as easy as it might
More information9 Ways to Join Two Datasets David Franklin, Independent Consultant, New Hampshire, USA
9 Ways to Join Two Datasets David Franklin, Independent Consultant, New Hampshire, USA ABSTRACT Joining or merging data is one of the fundamental actions carried out when manipulating data to bring it
More informationThe Power of PROC SQL Techniques and SAS Dictionary Tables in Handling Data
Paper PO31 The Power of PROC SQL Techniques and SAS Dictionary Tables in Handling Data MaryAnne DePesquo Hope, Health Services Advisory Group, Phoenix, Arizona Fen Fen Li, Health Services Advisory Group,
More informationData Quality Review for Missing Values and Outliers
Paper number: PH03 Data Quality Review for Missing Values and Outliers Ying Guo, i3, Indianapolis, IN Bradford J. Danner, i3, Lincoln, NE ABSTRACT Before performing any analysis on a dataset, it is often
More informationIntroduction to PROC SQL
Introduction to PROC SQL Steven First, Systems Seminar Consultants, Madison, WI ABSTRACT PROC SQL is a powerful Base SAS Procedure that combines the functionality of DATA and PROC steps into a single step.
More informationCHAPTER 7 Using Other SAS Software Products
77 CHAPTER 7 Using Other SAS Software Products Introduction 77 Using SAS DATA Step Features in SCL 78 Statements 78 Functions 79 Variables 79 Numeric Variables 79 Character Variables 79 Expressions 80
More informationQuicker Than Merge? Kirby Cossey, Texas State Auditor s Office, Austin, Texas
Paper 076-29 Quicker Than Merge? Kirby Cossey, Texas State Auditor s Office, Austin, Texas ABSTRACT How many times do you need to extract a few records from an extremely large dataset? INTRODUCTION In
More informationA General SAS Macro to Implement Optimal N:1 Propensity Score Matching Within a Maximum Radius
PharmaSUG 2015 - Paper HA05 A General SAS Macro to Implement Optimal N:1 Propensity Score Matching Within a Maximum Radius Kathy H. Fraeman, Evidera, Bethesda, MD ABSTRACT A propensity score is the probability
More informationT.I.P.S. (Techniques and Information for Programming in SAS )
Paper PO-088 T.I.P.S. (Techniques and Information for Programming in SAS ) Kathy Harkins, Carolyn Maass, Mary Anne Rutkowski Merck Research Laboratories, Upper Gwynedd, PA ABSTRACT: This paper provides
More informationIntroduction. Getting Started with the Macro Facility CHAPTER 1
1 CHAPTER 1 Introduction Getting Started with the Macro Facility 1 Replacing Text Strings Using Macro Variables 2 Generating SAS Code Using Macros 3 Inserting Comments in Macros 4 Macro Definition Containing
More informationTweaking your tables: Suppressing superfluous subtotals in PROC TABULATE
ABSTRACT Tweaking your tables: Suppressing superfluous subtotals in PROC TABULATE Steve Cavill, NSW Bureau of Crime Statistics and Research, Sydney, Australia PROC TABULATE is a great tool for generating
More informationSame Data Different Attributes: Cloning Issues with Data Sets Brian Varney, Experis Business Analytics, Portage, MI
Paper BB-02-2013 Same Data Different Attributes: Cloning Issues with Data Sets Brian Varney, Experis Business Analytics, Portage, MI ABSTRACT When dealing with data from multiple or unstructured data sources,
More informationA Quick and Easy Data Dictionary Macro Pete Lund, Looking Glass Analytics, Olympia, WA
A Quick and Easy Data Dictionary Macro Pete Lund, Looking Glass Analytics, Olympia, WA ABTRACT A good data dictionary is key to managing even a modest-sized project. There are limited tools available in
More informationUsing SAS software to fulfil an FDA request for database documentation
Using SAS software to fulfil an FDA request for database documentation Introduction Pantaleo Nacci, Adam Crisp Glaxo Wellcome R&D, UK Historically, a regulatory submission to seek approval for a new drug
More informationMapping Clinical Data to a Standard Structure: A Table Driven Approach
ABSTRACT Paper AD15 Mapping Clinical Data to a Standard Structure: A Table Driven Approach Nancy Brucken, i3 Statprobe, Ann Arbor, MI Paul Slagle, i3 Statprobe, Ann Arbor, MI Clinical Research Organizations
More informationSo Much Data, So Little Time: Splitting Datasets For More Efficient Run Times and Meeting FDA Submission Guidelines
Paper TT13 So Much Data, So Little Time: Splitting Datasets For More Efficient Run Times and Meeting FDA Submission Guidelines Anthony Harris, PPD, Wilmington, NC Robby Diseker, PPD, Wilmington, NC ABSTRACT
More information... ) city (city, cntyid, area, pop,.. )
PaperP829 PROC SQl - Is it a Required Tool for Good SAS Programming? Ian Whitlock, Westat Abstract No one SAS tool can be the answer to all problems. However, it should be hard to consider a SAS programmer
More informationThis Too Shall Pass: Passing Simple and Complex Parameters In and Out of Macros
ABSTRACT Paper 078-2018 This Too Shall Pass: Passing Simple and Complex Parameters In and Out of Macros Ted D. Williams, PharmD, BCPS, Magellan Method Even a rudimentary knowledge of SAS macros will highlight
More informationDifferent Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse
Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse Ben Cochran, The Bedford Group, Raleigh, NC Abstract Often SAS users need to access data from non- SAS
More informationTales from the Help Desk 6: Solutions to Common SAS Tasks
SESUG 2015 ABSTRACT Paper BB-72 Tales from the Help Desk 6: Solutions to Common SAS Tasks Bruce Gilsen, Federal Reserve Board, Washington, DC In 30 years as a SAS consultant at the Federal Reserve Board,
More informationABSTRACT INTRODUCTION MACRO. Paper RF
Paper RF-08-2014 Burst Reporting With the Help of PROC SQL Dan Sturgeon, Priority Health, Grand Rapids, Michigan Erica Goodrich, Priority Health, Grand Rapids, Michigan ABSTRACT Many SAS programmers need
More informationPhUSE US Connect 2018 Paper CT06 A Macro Tool to Find and/or Split Variable Text String Greater Than 200 Characters for Regulatory Submission Datasets
PhUSE US Connect 2018 Paper CT06 A Macro Tool to Find and/or Split Variable Text String Greater Than 200 Characters for Regulatory Submission Datasets Venkata N Madhira, Shionogi Inc, Florham Park, USA
More informationDavid Ghan SAS Education
David Ghan SAS Education 416 307-4515 David.ghan@sas.com Using SQL in SAS Victoria Area SAS User Group February 12, 2004 1. What is SQL? 2. Coding an SQL Query 3. Advanced Examples a. Creating macro variables
More informationUsing PROC SQL to Calculate FIRSTOBS David C. Tabano, Kaiser Permanente, Denver, CO
Using PROC SQL to Calculate FIRSTOBS David C. Tabano, Kaiser Permanente, Denver, CO ABSTRACT The power of SAS programming can at times be greatly improved using PROC SQL statements for formatting and manipulating
More informationSAS Online Training: Course contents: Agenda:
SAS Online Training: Course contents: Agenda: (1) Base SAS (6) Clinical SAS Online Training with Real time Projects (2) Advance SAS (7) Financial SAS Training Real time Projects (3) SQL (8) CV preparation
More informationDavid Franklin Independent SAS Consultant TheProgramersCabin.com
Countdown of the Top 10 Ways to Merge Data Trivia The film The Poseidon Adventure is based on a real life event that involved the Queen Mary in 1942 the ship was hit by a 92 foot wave which listed the
More informationOpen Problem for SUAVe User Group Meeting, November 26, 2013 (UVic)
Open Problem for SUAVe User Group Meeting, November 26, 2013 (UVic) Background The data in a SAS dataset is organized into variables and observations, which equate to rows and columns. While the order
More informationcapabilities and their overheads are therefore different.
Applications Development 3 Access DB2 Tables Using Keylist Extraction Berwick Chan, Kaiser Permanente, Oakland, Calif Raymond Wan, Raymond Wan Associate Inc., Oakland, Calif Introduction The performance
More informationProgram Validation: Logging the Log
Program Validation: Logging the Log Adel Fahmy, Symbiance Inc., Princeton, NJ ABSTRACT Program Validation includes checking both program Log and Logic. The program Log should be clear of any system Error/Warning
More informationSAS Macros for Grouping Count and Its Application to Enhance Your Reports
SAS Macros for Grouping Count and Its Application to Enhance Your Reports Shi-Tao Yeh, EDP Contract Services, Bala Cynwyd, PA ABSTRACT This paper provides two SAS macros, one for one grouping variable,
More information