Easy Solutions To %LET You Reduce Repetitive Programming

Ekaterina Roudneva
UC Davis


Abstract

Cleaning data and generating reports can sometimes involve using the same pieces of information or code over and over again. This can consist of running similar programs one at a time in a specific sequence or updating multiple macro variables or fields. Related programs might need to import the same exact data resulting in that data being read in multiple times. These approaches are redundant, prone to errors, and can be very time consuming. By using macro variables or recognizing similarities in the code and condensing them into fewer programs, it is possible to increase efficiency and reduce the need for copy and pasting. This paper will go over some techniques that help reduce repetitive tasks by recognizing parts of code that can be condensed. Topics include using %LET and PROC SQL SELECT INTO statements to create macro variables and use them to reference commonly used dates, folder paths, dataset names and variables. It will also discuss how to transform these macro variables to accommodate different formats such as alternate date styles. The last topic will examine using the %INCLUDE statement to run multiple programs from one main program, eliminating the need to run those programs one at a time.