The SET Statement and Beyond: Uses and Abuses of the SET Statement. S. David Riba, JADE Tech, Inc., Clearwater, FL
|
|
|
- Steven Lee Thompson
- 10 years ago
- Views:
Transcription
1 The SET Statement and Beyond: Uses and Abuses of the SET Statement S. David Riba, JADE Tech, Inc., Clearwater, FL ABSTRACT The SET statement is one of the most frequently used statements in the SAS System. It is also probably one of the more misused SAS statements because the SET statement typically works without much programmer input. Proper use of the SET statement is one of the key techniques to improving the efficiency of SAS programs. INTRODUCTION The function of the SET statement is to process existing SAS data sets as input for a DATA step. With no options specified, the SAS System sequentially reads each observation in the named data sets, one observation at a time, until there are no further observations to process. The SET statement is very flexible and has a variety of uses. With some planning by the SAS programmer, proper use of the SET statement and SET statement options can improve the efficiency of most SAS programs. This paper will look at the options for the SET statement and suggest some ways that they can be utilized. SET STATEMENT OVERVIEW The simplest form of the SET statement is SET dsname ; With no options specified, the SAS System sequentially reads each observation in the named data set(s), one observation at a time, until there are no further observations to process. If multiple data sets are listed, all observations in the first data set are read before the SAS Supervisor starts reading the second data set, etc. All variables in the original data set(s) are added to the Program Data Vector of the DATA Step. This process continues until an end of file condition occurs after reading the last observation in the last data set listed in the SET statement. To better understand the operations of the SET statement, there is a brief review of the SAS Supervisor and Program Data Vector concepts on the next page. Up to 50 SAS data sets can be specified in a single SET statement. All the data sets must exist, although they may be empty (contain no observations). A fatal error will occur and the DATA step will terminate if a data set name that does not exist is referenced in a SET statement. The SET statement can be used to: Concatenate multiple data sets SET dsname_1 dsname_2... dsname_n ; Each data set is read sequentially from the first observation in the first named data set to the last named observation in the last data set. All variables are added to the Program Data Vector. The attributes of the variables are based on the first occurence of each variable. If all variables are not present in all the data sets, the values will be set to missing where the observations are from data sets without the variables. If the variables have different attributes and have not been previously defined in the DATA step, the first data set that defines a variable also defines the attribute for that variable. An error condition occurs if the TYPE of a variable differs between the data sets (ie character variable in some data sets, but numeric variable in others). Interleave Multiple SAS Data Sets SET dsname_1 dsname_2... dsname_n ; BY varlist ; If the data sets are sorted, they can be interleaved based on order of the sorted variable(s). When a BY statement is used, all observations that belong to a particular BY group are read sequentially from each data set. When there are no more observations to read in any of the data sets for a particular BY group, the next BY group is selected and the process repeats itself. This continues until all observations in all the data sets have been read. There was a change in Version 6 of the SAS System that affects how the BY statement is applied: Prior to Version 6, the BY statement was global in a DATA step. All data sets listed with any SET statement in a DATA step had to be sorted in the BY variable order. If a DATA step had multiple SET statements, the BY statement applied to all the data sets listed. In Version 6, the BY statement applies only to the last encountered SET statement. Multiple SET statements now require multiple BY statements. Thus, it is now possible to have a SET statement with a BY statement and a SET statement with the POINT = option in the same DATA step
2 Combine Multiple SAS Data Sets SET dsname_2 ; In this example, the SAS Supervisor maintains two pointers, one for each data set. An observation would be read from data set dsname_1 followed by an observation from data set dsname_2, and so on until an end of file condition occurs in one of the data sets. The combination of the two data sets would form a single observation in the new data set. Where the same variables exist in both data sets, the values of the second data set would overlay the values of the first data set. If ( _n_ eq 1 ) THEN SET dsname_2 ; In this example, every observation in data set dsname_2 would be merged with the first observation in data set dsname_1. If the first data set had grand totals, for example, these values would be combined with every observation in the second data set. THE SAS SUPERVISOR AND THE SET STATEMENT The Program Data Vector (PDV) is a set of buffers that are managed by the SAS Supervisor to temporarily store every variable that is referenced in a DATA step. When SAS data sets are listed in a SET statement, an allocation must be made in the Program Data Vector buffers for each variable that is defined in every data set listed. The SAS Supervisor also controls the initialization of variables to missing between each iteration of the DATA step. In Version 6 of the SAS System, the Initialize to Missing (ITM) process has been optimized. There are several SET statement options that affect how the SAS Supervisor manages the Program Data Vector and the Initialize to Missing process. Effective use of these options can significantly improve the efficiency of a SAS program. An understanding of how the SAS Supervisor treats the SET statement and its options is essential to the proper selection of SET statement options. When the SAS Supervisor encounters a SET statement in a DATA step, the SAS Supervisor performs several actions: determines which data set to read and sets the IN = and END = variable values identifies the next observation to read from the data set assigns missing values to variables that will not be read from the current data set if the SET statement will read from a different data set than was last read copies the values of variables from the selected observation in the current data set to the Program Data Vector, uncompressing the input if necessary If multiple data sets are read with a BY statement, the SAS Supervisor additionally performs the following: selects a data set to read by looking ahead to the values of the variables in the BY statement for the next observation sets the appropriate FIRST. and LAST. variable values for the BY variables EFFICIENCY AND THE SET STATEMENT The key to effectively using SET statement options for the highest efficiency is very simple: Is your data: Know Thy Data Short and wide (few observations, many variables)? long and thin (many observations, few variables)? long and wide (many observations, many variables)? The type of data to be processed will affect the SET statement options to use for the most efficient program. If possible, try to test the alternatives to select the most efficient option for your data. SET STATEMENT DATA SET OPTIONS There are several data set options that can be specified with the SET statement. These options are enclosed in parentheses and follow immediately the name of the data set that they apply to. Many of these options are also used in the DATA statement, and PROC statements such as PROC SORT and PROC PRINT. SET dsname_1 ( OPTION = list ) dsname_2 ( OPTION = list ) ; The data set options function identical to the SAS statements of the same name, with one key difference. Unlike SAS statements which operate on the variables in the Program Data Vector, SET statement options operate on variables before they are transferred to the Program Data Vector
3 These data set options are: DROP = varlist KEEP = varlist FIRSTOBS = num IN = var OBS = num RENAME = varlist WHERE = condition The DROP = and KEEP = options specify which variables in the input data set are to be omitted or processed in the data step. They apply only to the data set name most recently referenced, so different DROP = or KEEP = lists can be specified when multiple data sets are listed with a single SET statement. SET dsname_1 dsname_2 ; DROP list ; SET dsname_1 ( drop = list ) dsname_2 ( drop = list ) ; Unlike the DROP statement, variables that are specified in a DROP = list are not available for use during a DATA step. If the same variable is specified in both a DROP = and KEEP = statement, the variable will be dropped. For data sets that are very wide (ie data sets with many variables), considerable processing efficiencies can be achieved by dropping unnecessary variables before they are added to the Program Data Vector. The RENAME = option renames variables exactly the same as the RENAME statement. However, since this is a SET statement data set option, the RENAME operation occurs before the variable is added to the Program Data Vector. Unlike the RENAME statement, your SAS code should reference the NEW name instead of the old name. SET dsname; oldname = value ; RENAME oldname = newname ; SET dsname (rename=(oldname=newname) ); newname = value ; The SAS Supervisor DROPs or KEEPs variables first when the DROP = or KEEP = data set options are specified. It is important, therefore, to DROP or KEEP the original names and not the RENAMEd names. The FIRSTOBS = and the OBS = data set options are often confused. Both options take a positive number as an argument. FIRSTOBS = specifies the observation number in a data set that is the starting observation for the SET statement. OBS = specifies the observation number that is the last observation in a data set to read. Thus, SET dsname ( firstobs = 100 obs = 50 ) ; is an impossibility and would result in a fatal error. However, SET dsname ( firstobs = 50 obs = 100 ) ; will sequentially read observation numbers 50 through 100 from data set dsname. The combination of the FIRSTOBS = and OBS = options creates some very useful capabilities: While debugging a SAS program, setting OBS = 0 is the same as setting the global OBS option to 0 for that DATA step -- the SAS Supervisor performs a syntax check but does not process any data. However, setting OBS = 0 as a data step option is more efficient than setting the global OBS option to 0 for that DATA step. It would be trivial to set the OBS = variable to a macro variable which could contain the value of 0 syntax check only x x observations the NOBS = variable read all observations (more on NOBS later) By changing the value of the macro variable that OBS = uses, it is possible to change a DATA step from test mode to production mode without changing any code. In the following example, a data set is combined with itself to calculate the change in a variable's value SET dsname_1 ( keep = total rename = ( total=oldtot ) ) ; SET dsname_1 ( firstobs = 2 ) ; delta = total - oldtot ; - 3 -
4 The SAS Supervisor maintains two read pointers into the same data set, one for each SET statement. For each pass of the DATA step, an observation is read from data set dsname_1 and then the next observation is read from the same data set. The RENAME = option is important to prevent the variable values from being replaced when the same variables are read with the second SET statement. The end of file condition will occur when the second SET statement reads the last observation in the data set. In effect, this example is an offset one to one merge with the same data set. Use of the FIRSTOBS = or OBS = options can be a very efficient method of selecting a subset of observations in a data set. If your program selects a subset of data, for example the first 100 records or the last 100 records, consider using FIRSTOBS = or OBS = instead of reading in all the records in a data set and then deleting the unwanted records. Note that the FIRSTOBS = and OBS = options can not be used with a WHERE statement or the WHERE = data set option. The FIRSTOBS = and OBS = options can be used with compressed data sets, but they function more slowly than if the data sets were not compressed. The IN = data set option is used with multiple data sets where it is important to know which data set contributed an observation. A separate IN = variable can be specified for each data set defined with the SET statement. The variable named by the IN = option has a value that is set to 1 for every observation that originated from the data set. SET dsname_1 ( in = in_1 ) dsname_2 ( in = in_2 ) ; IF ( in_1 ) THEN ---- ; ELSE IF ( in_2 ) THEN ---- ; The variables defined with the IN = option only exist for the duration of the DATA step and are not added to the data set. Do not DROP or KEEP these variables. The WHERE = data set option selects observations from a SAS data set that meet the conditions specified. It functions identical to the WHERE statement. However, the WHERE = data set option is more efficient than the WHERE statement, because only those observations that match the conditional test are transferred into the Program Data Vector. With the WHERE statement, all observations are read from the input data set and non-selected observations are discarded. The WHERE = option only selects those observations that match the criteria. SET dsname_1 ( where = ( condition ) ) dsname_2 ( where = ( condition ) ) ; If both a WHERE = and a WHERE statement are used in the same data step, the WHERE statement is ignored for those data sets that have a WHERE = condition defined. The WHERE = data set option can not be used with the POINT =, FIRSTOBS =, or OBS = data set options. SET STATEMENT OPTIONS Besides the data set options, there are several other options that are also used with the SET statement. With the exception of the newly available KEY = option, each of these options uses a SAS variable that is valid during the DATA step. However, these variables are not added to the final data set. Unlike the SET statement data set options, these options are not enclosed in parentheses. These SET statement options are: END = var KEY = index NOBS = var POINT = var The END = option is used to identify the last observation processed by a SET statement. It creates a variable whose value is set to 0 for overy observation except for the last observation in the last data set (end of file of the final data set). When the last observation is read, the variable value is set to 1. DATA step logic can now be used to perform specific tasks before the DATA step terminates. SET dsname_1 dsname_2 end = eof ; IF ( eof ) THEN DO ; Since the variable created by the END = option is not added to the final data set, it would be an error to try to DROP or KEEP the variable. The KEY = option retrieves observations from an indexed data set based on the index key, which can be either a simple key or a composite key. If no observations are found in the data set that match the value of the key variable(s), then an error condition occurs
5 SET dsname_2 key = indexvar ; The NOBS = option creates a variable which contains the total number of observations in the input data set(s). If multiple data sets are listed in the SET statement, the value in the NOBS = variable are the total number of observations in all the listed data sets. SET dsname_1 dsname_2 nobs = totobs ; Of key importance is that the value of the NOBS = variable is set by the SAS Supervisor at compile time. During the compile phase of a DATA step, the SAS Supervisor retrieves the number of observations in each data set listed in a SET statement from the header record of the data set. When the SAS System begins to execute the DATA step, the value for this variable is already defined and can be referenced immediately. Because the value of the NOBS = variable is already defined when the DATA step starts executing, it can be used before the SET statement is acted upon. The following example looks impossible, but is actually a very useful application of the NOBS = option: IF (0) then SET dsname ( drop=_all_ ) nobs=totobs; This statement assigns the total number of observations in data set dsname to a variable called totobs, which can be used anywhere in the DATA step. It is never executed, since the IF (0) condition can never be True. Also, the variables in data set dsname are never added to the Program Data Vector because of the DROP = _ALL_ option on the SET statement. The purpose of this statement is to store the number of observations in a data set in a variable called TOTOBS without adding the observations or variables in the data set to the Program Data Vector of the current DATA step. This might be useful in preventing a data set that has no observations from being used as input to update an existing data set. This example could be used with the following statement: IF ( totobs ) then SET dsname ; ELSE abort ; To define the number of observations in a data set in a macro variable (&N_OBS) for later use in a SAS program: DATA _NULL_ ; CALL SYMPUT ( 'n_obs', put ( n_obs, 5. ) ) ; SET dsname nobs = n_obs; The only executable statement in this DATA step is the CALL SYMPUT to create macro variable &N_OBS. The SET statement is never executed, but the value of variable n_obs is assigned at compile time. The POINT = option uses a numeric variable for direct (or random) access into a SAS data set. The value of the POINT = variable must be specified before it can be used. ptr = 100 ; SET dsname point = ptr ; Since any number can be specified as the value for the POINT = variable, it is important to verify that the number is a valid observation number (eg compare it to the variable created by the NOBS = option). If the pointer tries to access an observation number that is greater than the number of observations in the data set, an error condition occurs. The variable used for the POINT = option (the pointer) is temporary and is not added to the final data set. Do not try to DROP or KEEP the pointer variable. Also, do not use a variable that already exists in any of the data sets listed with the SET statement or some very unpredictable results may occur. If multiple data sets are listed with a single SET statement, the POINT = variable retrieves observations from the data sets as if they were concatenated. That is, the observation number between one and the last record of the last data set in the SET statement list. The POINT = option is not valid for compressed SAS data sets, transport files, SAS/ACCESS views, or SQL views that read data from external files. It is very important to be aware that since the POINT = option provides direct access to SAS data sets, it can not be used with a BY statement. It also can not be used with a WHERE statement or the WHERE = data set option. It is also important to be aware that continuous loops can occur since there is not always an end of file indicator when using the POINT = option. Provisions should be made to end the DATA step to prevent a continuous loop. DO ptr = lastrec to 1 by -1 ; SET dsname_1 point = ptr nobs = lastrec ; - 5 -
6 This example reads a data set in reverse order, last observation to first observation. Another use of the POINT = option is to generate a random sample of data. To select 100 random observations from a data set: DO _I_ = 1 to 100 ; ptr = ceil ( totobs * ranuni ( totobs ) ) ; SET dsname_1 point = ptr nobs = totobs ; The source of the pointer values can also be from another SAS data set. In this example, data set dsname_1 contains numeric variables START and STOP which define the observation numbers in data set dsname_2 that are to be read with the second SET statement. DO ptr = start to stop ; SET dsname_2 point = ptr ; It is important to be aware that direct access with the POINT = option is generally less efficient for large data sets. It is most efficient for small data sets or when reading up to a maximum of 20-25% of a data set. DO LOOPS AND THE SET STATEMENT Placing the SET statement inside a DO loop is usually more efficient than letting the SAS Supervisor control processing especially for large data sets. DO UNTIL (lastrec) ; SET dsname_1 dsname_2 end = lastrec ; -- Surprisingly, this example is generally more efficient than a simple SET statement because some operations of the SAS Supervisor are bypassed. The efficiencies that can be achieved by bypassing the SAS Supervisor have some trade-off costs. Bypassing the SAS Supervisor means that variables are no longer reset to missing before each observation is read from the input data sets. Since variables are not reset to missing, the SAS programmer needs to perform this task if necessary. Also, there is no implied output performed, so it is important to specify when to add data to the new data set with an OUTPUT statement. Finally, it is very important to define some condition when to stop processing the DATA step. Note the STOP statement at the end of the DATA step. Note that some changes to optimize Version 6 of the SAS System have decreased the efficiency gains achieved by putting the SET statement in a DO UNTIL loop. It would be advisable to test your proposed code on your current level of SAS software before implementing this type of example. The following example calculates a minimum, maximum, and sum for a variable in a data set, for use with every observation in that data set in the same DATA step. RETAIN minval maxval sumval ; IF ( _N_ eq 1 ) THEN DO UNTIL (lastrec) ; SET dsname_1 (keep = value) end = lastrec; minval = min ( minval, value ) ; maxval = max ( maxval, value ) ; sumval = sum ( sumval, value ) ; CONCLUSION This paper examined each of the options for the SET statement, considering the efficiency issues that applied to each option. Options such as DROP = and KEEP = can impact the processing of data sets with many variables. Options such as FIRSTOBS =, OBS =, WHERE =, and POINT = can select the observations to read before they are copied to the Program Data Vector by the SAS Supervisor. These options can be combined for the highest efficiency. The key is an understanding of the data to be processed and how the SAS Supervisor interacts with the SET statement. A proper understanding of the SET statement and the options that can modify it can have a significant impact on the efficiency of the DATA step. When reading SAS data sets, the SET statement can control which variables to include in the Program Data Vector, which observations to read from a SAS data set, or both. Proper use of the SET statement and SET statement options can enhance program efficiency, while improper use can reduce DATA step efficiency
7 REFERENCES Howard, N. (1991). Efficiency Techniques for Improving I/O and Processing Time in the Data Step. Proceedings of the Sixteenth Annual SAS Users Group International Conference. SAS Institute, Inc., Cary, NC. pp Rabb, M. G., Henderson, D. J., and Polzin, J. A. (1992). The SAS System Supervisor - A Version 6 Update. Proceedings of the Seventeenth Annual SAS Users Group International Conference. SAS Institute, Inc., Cary, NC. pp SAS Institute, Inc., SAS Language: Reference, Version 6, First Edition Cary, NC. SAS Institute Inc., Schallert, Bill (1992). Use of the KEEP and DROP Concept in Batch SAS Programs. Proceedings of the Seventeenth Annual SAS Users Group International Conference. SAS Institute, Inc., Cary, NC. pp Thornton, R. G. and Rabb, M. G. (1988). Advanced Set and Merge Processing. Proceedings of the Thirteenth Annual SAS Users Group International Conference. SAS Institute, Inc., Cary, NC. pp Zeid, Aiman. (1989). The SAS Supervisor and SET / MERGE Processing. Proceedings of the Fourteenth Annual SAS Users Group International Conference. SAS Institute, Inc., Cary, NC. pp ACKNOWLEDGEMENTS SAS is a registered trademark of SAS Institute Inc. in the USA and other countries. indicates USA registration. AUTHOR The author may be contacted at: S. David Riba JADE Tech, Inc. P O Box 4517 Clearwater, FL (813) INTERNET: [email protected] This paper is available for download from the author s Web site: SPEAKER BIO: S. David Riba is CEO of JADE Tech, Inc., a SAS Institute Quality Partner who specializes entirely in applications development and training in the SAS System. Dave is the founder and President of the Florida Gulf Coast SAS Users Group. He chartered and served as Co-Chair of the first SouthEast SAS Users Group conference, SESUG '93, and serves on the Executive Boards of both the SouthEast SAS Users Group and the Consultants SAS Users Group (CONSUG). His first SUGI was in 1983, and he has been actively involved in both SUGI and the Regional SAS Users Group community since then. He has presented papers and assisted in various capacities at SUGI, SESUG, NESUG, MWSUG, SCSUG, and PharmaSUG. Dave is an unrepentant SAS bigot. His major areas of interest are efficient programming techniques and applications development using the SAS System, particularly using Screen Control Language with SAS/AF and FRAME technology
Programming Idioms Using the SET Statement
Programming Idioms Using the SET Statement Jack E. Fuller, Trilogy Consulting Corporation, Kalamazoo, MI ABSTRACT While virtually every programmer of base SAS uses the SET statement, surprisingly few programmers
More Tales from the Help Desk: Solutions for Simple SAS Mistakes Bruce Gilsen, Federal Reserve Board
More Tales from the Help Desk: Solutions for Simple SAS Mistakes Bruce Gilsen, Federal Reserve Board INTRODUCTION In 20 years as a SAS consultant at the Federal Reserve Board, I have seen SAS users make
New Tricks for an Old Tool: Using Custom Formats for Data Validation and Program Efficiency
New Tricks for an Old Tool: Using Custom Formats for Data Validation and Program Efficiency S. David Riba, JADE Tech, Inc., Clearwater, FL ABSTRACT PROC FORMAT is one of the old standards among SAS Procedures,
Top Ten SAS Performance Tuning Techniques
Paper AD39 Top Ten SAS Performance Tuning Techniques Kirk Paul Lafler, Software Intelligence Corporation, Spring Valley, California Abstract The Base-SAS software provides users with many choices for accessing,
Subsetting Observations from Large SAS Data Sets
Subsetting Observations from Large SAS Data Sets Christopher J. Bost, MDRC, New York, NY ABSTRACT This paper reviews four techniques to subset observations from large SAS data sets: MERGE, PROC SQL, user-defined
Table Lookups: From IF-THEN to Key-Indexing
Paper 158-26 Table Lookups: From IF-THEN to Key-Indexing Arthur L. Carpenter, California Occidental Consultants ABSTRACT One of the more commonly needed operations within SAS programming is to determine
How and When to Use WHERE J. Meimei Ma, Quintiles, Research Triangle Park, NC Sandra Schlotzhauer, Schlotzhauer Consulting, Chapel Hill, NC
How and When to Use WHERE J. Meimei Ma, Quintiles, Research Triangle Park, NC Sandra Schlotzhauer, Schlotzhauer Consulting, Chapel Hill, NC INTRODUCTION This tutorial explores the various types of WHERE
Paper 109-25 Merges and Joins Timothy J Harrington, Trilogy Consulting Corporation
Paper 109-25 Merges and Joins Timothy J Harrington, Trilogy Consulting Corporation Abstract This paper discusses methods of joining SAS data sets. The different methods and the reasons for choosing a particular
SAS PROGRAM EFFICIENCY FOR BEGINNERS. Bruce Gilsen, Federal Reserve Board
SAS PROGRAM EFFICIENCY FOR BEGINNERS Bruce Gilsen, Federal Reserve Board INTRODUCTION This paper presents simple efficiency techniques that can benefit inexperienced SAS software users on all platforms.
KEYWORDS ARRAY statement, DO loop, temporary arrays, MERGE statement, Hash Objects, Big Data, Brute force Techniques, PROC PHREG
Paper BB-07-2014 Using Arrays to Quickly Perform Fuzzy Merge Look-ups: Case Studies in Efficiency Arthur L. Carpenter California Occidental Consultants, Anchorage, AK ABSTRACT Merging two data sets when
Paper 2917. Creating Variables: Traps and Pitfalls Olena Galligan, Clinops LLC, San Francisco, CA
Paper 2917 Creating Variables: Traps and Pitfalls Olena Galligan, Clinops LLC, San Francisco, CA ABSTRACT Creation of variables is one of the most common SAS programming tasks. However, sometimes it produces
Data Presentation. Paper 126-27. Using SAS Macros to Create Automated Excel Reports Containing Tables, Charts and Graphs
Paper 126-27 Using SAS Macros to Create Automated Excel Reports Containing Tables, Charts and Graphs Tugluke Abdurazak Abt Associates Inc. 1110 Vermont Avenue N.W. Suite 610 Washington D.C. 20005-3522
Efficient Techniques and Tips in Handling Large Datasets Shilong Kuang, Kelley Blue Book Inc., Irvine, CA
Efficient Techniques and Tips in Handling Large Datasets Shilong Kuang, Kelley Blue Book Inc., Irvine, CA ABSTRACT When we work on millions of records, with hundreds of variables, it is crucial how we
Writing cleaner and more powerful SAS code using macros. Patrick Breheny
Writing cleaner and more powerful SAS code using macros Patrick Breheny Why Use Macros? Macros automatically generate SAS code Macros allow you to make more dynamic, complex, and generalizable SAS programs
Simple Rules to Remember When Working with Indexes Kirk Paul Lafler, Software Intelligence Corporation, Spring Valley, California
Simple Rules to Remember When Working with Indexes Kirk Paul Lafler, Software Intelligence Corporation, Spring Valley, California Abstract SAS users are always interested in learning techniques related
Paper 70-27 An Introduction to SAS PROC SQL Timothy J Harrington, Venturi Partners Consulting, Waukegan, Illinois
Paper 70-27 An Introduction to SAS PROC SQL Timothy J Harrington, Venturi Partners Consulting, Waukegan, Illinois Abstract This paper introduces SAS users with at least a basic understanding of SAS data
SAS Comments How Straightforward Are They? Jacksen Lou, Merck & Co.,, Blue Bell, PA 19422
SAS Comments How Straightforward Are They? Jacksen Lou, Merck & Co.,, Blue Bell, PA 19422 ABSTRACT SAS comment statements typically use conventional symbols, *, %*, /* */. Most programmers regard SAS commenting
LEADS AND LAGS: HANDLING QUEUES IN THE SAS DATA STEP
LEADS AND LAGS: HANDLING QUEUES IN THE SAS DATA STEP Mark Keintz, Wharton Research Data Services, University of Pennsylvania ASTRACT From stock price histories to hospital stay records, analysis of time
From The Little SAS Book, Fifth Edition. Full book available for purchase here.
From The Little SAS Book, Fifth Edition. Full book available for purchase here. Acknowledgments ix Introducing SAS Software About This Book xi What s New xiv x Chapter 1 Getting Started Using SAS Software
USING SAS WITH ORACLE PRODUCTS FOR DATABASE MANAGEMENT AND REPORTING
USING SAS WITH ORACLE PRODUCTS FOR DATABASE MANAGEMENT AND REPORTING Henry W. Buffum, R. O. W. ScIences, Inc. Darryl J. Keith, U.S. Environmental Protection Agency Abstract: Data for a large environmental
Using SAS With a SQL Server Database. M. Rita Thissen, Yan Chen Tang, Elizabeth Heath RTI International, RTP, NC
Using SAS With a SQL Server Database M. Rita Thissen, Yan Chen Tang, Elizabeth Heath RTI International, RTP, NC ABSTRACT Many operations now store data in relational databases. You may want to use SAS
B) Mean Function: This function returns the arithmetic mean (average) and ignores the missing value. E.G: Var=MEAN (var1, var2, var3 varn);
SAS-INTERVIEW QUESTIONS 1. What SAS statements would you code to read an external raw data file to a DATA step? Ans: Infile and Input statements are used to read external raw data file to a Data Step.
Leads and Lags: Static and Dynamic Queues in the SAS DATA STEP
Paper 7-05 Leads and Lags: Static and Dynamic Queues in the SAS DATA STEP Mark Keintz, Wharton Research Data Services ABSTRACT From stock price histories to hospital stay records, analysis of time series
How to Reduce the Disk Space Required by a SAS Data Set
How to Reduce the Disk Space Required by a SAS Data Set Selvaratnam Sridharma, U.S. Census Bureau, Washington, DC ABSTRACT SAS datasets can be large and disk space can often be at a premium. In this paper,
Importing Excel File using Microsoft Access in SAS Ajay Gupta, PPD Inc, Morrisville, NC
ABSTRACT PharmaSUG 2012 - Paper CC07 Importing Excel File using Microsoft Access in SAS Ajay Gupta, PPD Inc, Morrisville, NC In Pharmaceuticals/CRO industries, Excel files are widely use for data storage.
A Faster Index for sorted SAS Datasets
A Faster Index for sorted SAS Datasets Mark Keintz Wharton Research Data Services, Philadelphia PA ABSTRACT In a NESUG 2007 paper with Shuguang Zhang, I demonstrated a condensed index which provided significant
Using Macros to Automate SAS Processing Kari Richardson, SAS Institute, Cary, NC Eric Rossland, SAS Institute, Dallas, TX
Paper 126-29 Using Macros to Automate SAS Processing Kari Richardson, SAS Institute, Cary, NC Eric Rossland, SAS Institute, Dallas, TX ABSTRACT This hands-on workshop shows how to use the SAS Macro Facility
PO-18 Array, Hurray, Array; Consolidate or Expand Your Input Data Stream Using Arrays
Array, Hurray, Array; Consolidate or Expand Your Input Data Stream Using Arrays, continued SESUG 2012 PO-18 Array, Hurray, Array; Consolidate or Expand Your Input Data Stream Using Arrays William E Benjamin
SAS Client-Server Development: Through Thick and Thin and Version 8
SAS Client-Server Development: Through Thick and Thin and Version 8 Eric Brinsfield, Meridian Software, Inc. ABSTRACT SAS Institute has been a leader in client-server technology since the release of SAS/CONNECT
Alternative Methods for Sorting Large Files without leaving a Big Disk Space Footprint
Alternative Methods for Sorting Large Files without leaving a Big Disk Space Footprint Rita Volya, Harvard Medical School, Boston, MA ABSTRACT Working with very large data is not only a question of efficiency
Everything you wanted to know about MERGE but were afraid to ask
TS- 644 Janice Bloom Everything you wanted to know about MERGE but were afraid to ask So you have read the documentation in the SAS Language Reference for MERGE and it still does not make sense? Rest assured
Advanced Tutorials. Numeric Data In SAS : Guidelines for Storage and Display Paul Gorrell, Social & Scientific Systems, Inc., Silver Spring, MD
Numeric Data In SAS : Guidelines for Storage and Display Paul Gorrell, Social & Scientific Systems, Inc., Silver Spring, MD ABSTRACT Understanding how SAS stores and displays numeric data is essential
CHAPTER 1 Overview of SAS/ACCESS Interface to Relational Databases
3 CHAPTER 1 Overview of SAS/ACCESS Interface to Relational Databases About This Document 3 Methods for Accessing Relational Database Data 4 Selecting a SAS/ACCESS Method 4 Methods for Accessing DBMS Tables
How to Use the WHERE Statement
How to Use the WHERE Statement Juliana Meimei Ma, Quintiles INTRODUCTION This tutorial explores the WHERE statement used in both DATA steps and Procedures as well as the WHERE data set option. With the
SAS PASSTHRU to Microsoft SQL Server using ODBC Nina L. Werner, Madison, WI
Paper SA-03-2014 SAS PASSTHRU to Microsoft SQL Server using ODBC Nina L. Werner, Madison, WI ABSTRACT I wish I could live in SAS World I do much of my data analysis there. However, my current environment
SUGI 29 Coders' Corner
Paper 074-29 Tales from the Help Desk: Solutions for Simple SAS Mistakes Bruce Gilsen, Federal Reserve Board INTRODUCTION In 19 years as a SAS consultant at the Federal Reserve Board, I have seen SAS users
You have got SASMAIL!
You have got SASMAIL! Rajbir Chadha, Cognizant Technology Solutions, Wilmington, DE ABSTRACT As SAS software programs become complex, processing times increase. Sitting in front of the computer, waiting
Managing Tables in Microsoft SQL Server using SAS
Managing Tables in Microsoft SQL Server using SAS Jason Chen, Kaiser Permanente, San Diego, CA Jon Javines, Kaiser Permanente, San Diego, CA Alan L Schepps, M.S., Kaiser Permanente, San Diego, CA Yuexin
Extending the Data Warehouse: An Introduction to OLE DB
Extending the Data Warehouse: An Introduction to OLE DB 7Â(EZMHÂ6MFEÂ.%()Â8IGLÂ-RGÂ'PIEV[EXIVÂ*0 ABSTRACT Now that you have your data warehoused, how do you share that information with others who need
Preparing your data for analysis using SAS. Landon Sego 24 April 2003 Department of Statistics UW-Madison
Preparing your data for analysis using SAS Landon Sego 24 April 2003 Department of Statistics UW-Madison Assumptions That you have used SAS at least a few times. It doesn t matter whether you run SAS in
Creating External Files Using SAS Software
Creating External Files Using SAS Software Clinton S. Rickards Oxford Health Plans, Norwalk, CT ABSTRACT This paper will review the techniques for creating external files for use with other software. This
Storing and Using a List of Values in a Macro Variable
Storing and Using a List of Values in a Macro Variable Arthur L. Carpenter California Occidental Consultants, Oceanside, California ABSTRACT When using the macro language it is not at all unusual to need
Effective Use of SQL in SAS Programming
INTRODUCTION Effective Use of SQL in SAS Programming Yi Zhao Merck & Co. Inc., Upper Gwynedd, Pennsylvania Structured Query Language (SQL) is a data manipulation tool of which many SAS programmers are
Tales from the Help Desk 3: More Solutions for Simple SAS Mistakes Bruce Gilsen, Federal Reserve Board
Tales from the Help Desk 3: More Solutions for Simple SAS Mistakes Bruce Gilsen, Federal Reserve Board INTRODUCTION In 20 years as a SAS consultant at the Federal Reserve Board, I have seen SAS users make
Using Pharmacovigilance Reporting System to Generate Ad-hoc Reports
Using Pharmacovigilance Reporting System to Generate Ad-hoc Reports Jeff Cai, Amylin Pharmaceuticals, Inc., San Diego, CA Jay Zhou, Amylin Pharmaceuticals, Inc., San Diego, CA ABSTRACT To supplement Oracle
Fun with PROC SQL Darryl Putnam, CACI Inc., Stevensville MD
NESUG 2012 Fun with PROC SQL Darryl Putnam, CACI Inc., Stevensville MD ABSTRACT PROC SQL is a powerful yet still overlooked tool within our SAS arsenal. PROC SQL can create tables, sort and summarize data,
Optimizing System Performance by Monitoring UNIX Server with SAS
Optimizing System Performance by Monitoring UNIX Server with SAS Sam Mao, Quintiles, Inc., Kansas City, MO Jay Zhou, Quintiles, Inc., Kansas City, MO ABSTRACT To optimize system performance and maximize
LEADS AND LAGS IN SAS
LEDS ND LGS IN SS Mark Keintz, Wharton Research Data Services, University of Pennsylvania STRCT nalysis of time series data often requires use of lagged (and occasionally lead) values of one or more analysis
Statistics and Analysis. Quality Control: How to Analyze and Verify Financial Data
Abstract Quality Control: How to Analyze and Verify Financial Data Michelle Duan, Wharton Research Data Services, Philadelphia, PA As SAS programmers dealing with massive financial data from a variety
9.1 SAS. SQL Query Window. User s Guide
SAS 9.1 SQL Query Window User s Guide The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2004. SAS 9.1 SQL Query Window User s Guide. Cary, NC: SAS Institute Inc. SAS
Imelda C. Go, South Carolina Department of Education, Columbia, SC
PO 003 Matching SAS Data Sets with PROC SQL: If at First You Don t Succeed, Match, Match Again ABSTRACT Imelda C. Go, South Carolina Department of Education, Columbia, SC Two data sets are often matched
How to Use SDTM Definition and ADaM Specifications Documents. to Facilitate SAS Programming
How to Use SDTM Definition and ADaM Specifications Documents to Facilitate SAS Programming Yan Liu Sanofi Pasteur ABSTRCT SDTM and ADaM implementation guides set strict requirements for SDTM and ADaM variable
AN INTRODUCTION TO MACRO VARIABLES AND MACRO PROGRAMS Mike S. Zdeb, New York State Department of Health
AN INTRODUCTION TO MACRO VARIABLES AND MACRO PROGRAMS Mike S. Zdeb, New York State Department of Health INTRODUCTION There are a number of SAS tools that you may never have to use. Why? The main reason
Macros from Beginning to Mend A Simple and Practical Approach to the SAS Macro Facility
Macros from Beginning to Mend A Simple and Practical Approach to the SAS Macro Facility Michael G. Sadof, MGS Associates, Inc., Bethesda, MD. ABSTRACT The macro facility is an important feature of the
FINDING ORACLE TABLE METADATA WITH PROC CONTENTS
Finding Oracle Table Metadata: When PROC CONTENTS Is Not Enough Jeremy W. Poling, B&W Y-12 L.L.C., Oak Ridge, TN ABSTRACT Complex Oracle databases often contain hundreds of linked tables. For SAS/ACCESS
Managing very large EXCEL files using the XLS engine John H. Adams, Boehringer Ingelheim Pharmaceutical, Inc., Ridgefield, CT
Paper AD01 Managing very large EXCEL files using the XLS engine John H. Adams, Boehringer Ingelheim Pharmaceutical, Inc., Ridgefield, CT ABSTRACT The use of EXCEL spreadsheets is very common in SAS applications,
Foundations & Fundamentals. A PROC SQL Primer. Matt Taylor, Carolina Analytical Consulting, LLC, Charlotte, NC
A PROC SQL Primer Matt Taylor, Carolina Analytical Consulting, LLC, Charlotte, NC ABSTRACT Most SAS programmers utilize the power of the DATA step to manipulate their datasets. However, unless they pull
Beyond the Basics: Advanced REPORT Procedure Tips and Tricks Updated for SAS 9.2 Allison McMahill Booth, SAS Institute Inc.
ABSTRACT PharmaSUG 2011 - Paper SAS-AD02 Beyond the Basics: Advanced REPORT Procedure Tips and Tricks Updated for SAS 9.2 Allison McMahill Booth, SAS Institute Inc., Cary, NC, USA This paper is an update
Choosing the Best Method to Create an Excel Report Romain Miralles, Clinovo, Sunnyvale, CA
Choosing the Best Method to Create an Excel Report Romain Miralles, Clinovo, Sunnyvale, CA ABSTRACT PROC EXPORT, LIBNAME, DDE or excelxp tagset? Many techniques exist to create an excel file using SAS.
Retrieving Data from Large DB2 Tables Based on Keys in SAS : The Sequel
Introduction and Overview Over the last few years, a number of papers have been presented at SUGI and regional conferences discussing the problem of how to extract data from one or more DB2 tables when
UNIX Comes to the Rescue: A Comparison between UNIX SAS and PC SAS
UNIX Comes to the Rescue: A Comparison between UNIX SAS and PC SAS Chii-Dean Lin, San Diego State University, San Diego, CA Ming Ji, San Diego State University, San Diego, CA ABSTRACT Running SAS under
Analyzing the Server Log
87 CHAPTER 7 Analyzing the Server Log Audience 87 Introduction 87 Starting the Server Log 88 Using the Server Log Analysis Tools 88 Customizing the Programs 89 Executing the Driver Program 89 About the
Better Safe than Sorry: A SAS Macro to Selectively Back Up Files
Better Safe than Sorry: A SAS Macro to Selectively Back Up Files Jia Wang, Data and Analytic Solutions, Inc., Fairfax, VA Zhengyi Fang, Social & Scientific Systems, Inc., Silver Spring, MD ABSTRACT SAS
File Management. Chapter 12
Chapter 12 File Management File is the basic element of most of the applications, since the input to an application, as well as its output, is usually a file. They also typically outlive the execution
Programming Tricks For Reducing Storage And Work Space Curtis A. Smith, Defense Contract Audit Agency, La Mirada, CA.
Paper 23-27 Programming Tricks For Reducing Storage And Work Space Curtis A. Smith, Defense Contract Audit Agency, La Mirada, CA. ABSTRACT Have you ever had trouble getting a SAS job to complete, although
Chapter 13: Query Processing. Basic Steps in Query Processing
Chapter 13: Query Processing! Overview! Measures of Query Cost! Selection Operation! Sorting! Join Operation! Other Operations! Evaluation of Expressions 13.1 Basic Steps in Query Processing 1. Parsing
Tips and Tricks for Creating Multi-Sheet Microsoft Excel Workbooks the Easy Way with SAS. Vincent DelGobbo, SAS Institute Inc.
Paper HOW-071 Tips and Tricks for Creating Multi-Sheet Microsoft Excel Workbooks the Easy Way with SAS Vincent DelGobbo, SAS Institute Inc., Cary, NC ABSTRACT Transferring SAS data and analytical results
Search and Replace in SAS Data Sets thru GUI
Search and Replace in SAS Data Sets thru GUI Edmond Cheng, Bureau of Labor Statistics, Washington, DC ABSTRACT In managing data with SAS /BASE software, performing a search and replace is not a straight
Nine Steps to Get Started using SAS Macros
Paper 56-28 Nine Steps to Get Started using SAS Macros Jane Stroupe, SAS Institute, Chicago, IL ABSTRACT Have you ever heard your coworkers rave about macros? If so, you've probably wondered what all the
The Power of CALL SYMPUT DATA Step Interface by Examples Yunchao (Susan) Tian, Social & Scientific Systems, Inc., Silver Spring, MD
Paper 052-29 The Power of CALL SYMPUT DATA Step Interface by Examples Yunchao (Susan) Tian, Social & Scientific Systems, Inc., Silver Spring, MD ABSTRACT AND INTRODUCTION CALL SYMPUT is a SAS language
Demystifying PROC SQL Join Algorithms Kirk Paul Lafler, Software Intelligence Corporation
Paper TU01 Demystifying PROC SQL Join Algorithms Kirk Paul Lafler, Software Intelligence Corporation ABSTRACT When it comes to performing PROC SQL joins, users supply the names of the tables for joining
SAS Logic Coding Made Easy Revisit User-defined Function Songtao Jiang, Boston Scientific Corporation, Marlborough, MA
ABSTRACT PharmaSUG 2013 - Paper CC04 SAS Logic Coding Made Easy Revisit User-defined Function Songtao Jiang, Boston Scientific Corporation, Marlborough, MA SAS programmers deal with programming logics
Raima Database Manager Version 14.0 In-memory Database Engine
+ Raima Database Manager Version 14.0 In-memory Database Engine By Jeffrey R. Parsons, Senior Engineer January 2016 Abstract Raima Database Manager (RDM) v14.0 contains an all new data storage engine optimized
DiskPulse DISK CHANGE MONITOR
DiskPulse DISK CHANGE MONITOR User Manual Version 7.9 Oct 2015 www.diskpulse.com [email protected] 1 1 DiskPulse Overview...3 2 DiskPulse Product Versions...5 3 Using Desktop Product Version...6 3.1 Product
File Management. File Management
File Management 1 File Management File management system consists of system utility programs that run as privileged applications Input to applications is by means of a file Output is saved in a file for
SUGI 29 Applications Development
Backing up File Systems with Hierarchical Structure Using SAS/CONNECT Fagen Xie, Kaiser Permanent Southern California, California, USA Wansu Chen, Kaiser Permanent Southern California, California, USA
The Essentials of Finding the Distinct, Unique, and Duplicate Values in Your Data
The Essentials of Finding the Distinct, Unique, and Duplicate Values in Your Data Carter Sevick MS, DoD Center for Deployment Health Research, San Diego, CA ABSTRACT Whether by design or by error there
Note: The where clause of the SUBSET statement is sent "as is" to Oracle, so it must contain correct Oracle syntax.
Optimizing Data Extraction from Oracle Tables Caroline Bahler, Meridian Software, Inc. Abstract The SAS/ACCESS product for Oracle offers a fast and easy interface for reading Oracle tables - access views
Emailing Automated Notification of Errors in a Batch SAS Program Julie Kilburn, City of Hope, Duarte, CA Rebecca Ottesen, City of Hope, Duarte, CA
Emailing Automated Notification of Errors in a Batch SAS Program Julie Kilburn, City of Hope, Duarte, CA Rebecca Ottesen, City of Hope, Duarte, CA ABSTRACT With multiple programmers contributing to a batch
Performing Queries Using PROC SQL (1)
SAS SQL Contents Performing queries using PROC SQL Performing advanced queries using PROC SQL Combining tables horizontally using PROC SQL Combining tables vertically using PROC SQL 2 Performing Queries
Developing an On-Demand Web Report Platform Using Stored Processes and SAS Web Application Server
Paper 10740-2016 Developing an On-Demand Web Report Platform Using Stored Processes and SAS Web Application Server ABSTRACT Romain Miralles, Genomic Health. As SAS programmers, we often develop listings,
Introduction to Criteria-based Deduplication of Records, continued SESUG 2012
SESUG 2012 Paper CT-11 An Introduction to Criteria-based Deduplication of Records Elizabeth Heath RTI International, RTP, NC Priya Suresh RTI International, RTP, NC ABSTRACT When survey respondents are
Data Warehousing. Paper 133-25
Paper 133-25 The Power of Hybrid OLAP in a Multidimensional World Ann Weinberger, SAS Institute Inc., Cary, NC Matthias Ender, SAS Institute Inc., Cary, NC ABSTRACT Version 8 of the SAS System brings powerful
The Advantages of Using RAID
1 Quick Guide to the SPD Engine Disk-I/O Set-Up SPD Engine Disk-I/O Set-Up 1 Disk Striping and RAIDs 2 Metadata Area Configuration 3 Assigning a Metadata Area 3 Metadata Space Requirements 3 Data Area
Parallel Data Preparation with the DS2 Programming Language
ABSTRACT Paper SAS329-2014 Parallel Data Preparation with the DS2 Programming Language Jason Secosky and Robert Ray, SAS Institute Inc., Cary, NC and Greg Otto, Teradata Corporation, Dayton, OH A time-consuming
Salary. Cumulative Frequency
HW01 Answering the Right Question with the Right PROC Carrie Mariner, Afton-Royal Training & Consulting, Richmond, VA ABSTRACT When your boss comes to you and says "I need this report by tomorrow!" do
PROC SQL for SQL Die-hards Jessica Bennett, Advance America, Spartanburg, SC Barbara Ross, Flexshopper LLC, Boca Raton, FL
PharmaSUG 2015 - Paper QT06 PROC SQL for SQL Die-hards Jessica Bennett, Advance America, Spartanburg, SC Barbara Ross, Flexshopper LLC, Boca Raton, FL ABSTRACT Inspired by Christianna William s paper on
Oracle Database: SQL and PL/SQL Fundamentals
Oracle University Contact Us: 1.800.529.0165 Oracle Database: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn This course is designed to deliver the fundamentals of SQL and PL/SQL along
