# Paper Creating Variables: Traps and Pitfalls Olena Galligan, Clinops LLC, San Francisco, CA

Size: px
Start display at page:

Download "Paper 2917. Creating Variables: Traps and Pitfalls Olena Galligan, Clinops LLC, San Francisco, CA"

Transcription

1 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 unexpected results without an error or warning message in the SAS log. These unexpected results could occur while performing illegal operations such as division by zero or attempting calculations involving missing values. Or they could happen while doing calculations in DATA steps containing MERGE or SET statements. One should also be beware of the frequent issues concerning numeric comparisons, concatenation of character variables and order of evaluation of numeric variables. This paper examines these issues, points out what to look for in note messages in SAS log and offers defensive programming techniques. ROUNDING TO DECIMAL PLACES According to SAS 9.2 Language Reference: Concepts (p.42), imprecision can cause problems with comparisons. Consider, for example, computations involving fraction 1/9: data _null_; x=1/9; if x=.111 then y = 1; put x= / y=; The resulting SAS Log output is shown below: x= y=. Trap: Some numbers cannot be represented exactly in a decimal notation. Good Programming Practice: use the ROUND( ) functions whenever fractions are involved: data _null_; x=1/9; if round(x,.001) =.111 then y = 1; put y=; And we get the correct result: y=1 NUMERIC REPRESENTATION (ROUND-OFF PRECISION) ERROR Consider the following example modified from SAS Support website at data test; x = ; if x=3.8 then var1=1; else var1=0; put var1= ; 1

2 SAS Log: var1=0 However, if you observe the data set created, you ll see that in fact, x=3.8, and therefore, var1 should be equal to 1, not zero! Here, var1 is not equal to 1 although it s the assumption that many people would make. Trap: The reason for this is that without var1 s format defined by the user, SAS uses the default format for var1 BEST12. Good programming practice with numerical variables would be to use the widest BESTw.format BEST32., along with the ROUND( ) function: data test; x = ; if round(x,.1)=3.8 then var1=1; else var1=0; put var1= ; format x best32.; The resulting output is correct: MERGING DATA SETS According to Malachy J. Foley in MATCH-MERGING: 20 Some Traps and How to Avoid Them, "Use only the basic 4-statement match-merge and to do all other processing in a separate DATA step. In other words, whenever possible, NEVER use a WHERE, an IF statement, an assignment statement, or anything else in the match-merge code. If manipulation is required, if at all possible, do it in a separate DATA step after the merge DATA step. This is extreme, but it works. And here s why. When MERGE statement is present, all input variables are initialized to missing only at the beginning of each BY group. Within the same BY group, values of all input variables will be automatically retained for the next iteration. The effect is similar to RETAIN statement. Consider these data sets: Data1: Data2: 2

3 data data3; merge data1 data2; by ID; if GRADE='D' then GOOD_POOR='Poor'; Trap: The second and third records are wrong since GRADE is B but GOOD_POOR is Poor! The value for GOOD_POOR for observation #2 has also been retained also for observations #3 and 4. The reason is because observations 3 and 4 belong to the same BY group as observation #2. Value for GOOD_POOR for observation #5 is correct since it belongs to the different BY group and was reset. And that is why it s a good programming practice not to perform any calculations in the data step that contains MERGE or SET statements. RETAIN STATEMENT According to SAS Online documentation, RETAIN statement causes a variable that is created by an INPUT or assignment statement to retain its value from one iteration of the DATA step to the next. Here are some points associated with frequent errors when applying RETAIN statement: FORGETTING TO RESET THE RETAINED VARIABLES Let s see what happens if you forget to reset the retained variables. Take this data set as an example: Data set TEST1: We want to retain the value of VAR3 in the (VAR1, VAR2) combination, provided that VAR2 is not missing. proc sort data=test1; by var1 var2; data test2; set test1; by var1 var2; retain var4; if first.var1 and var2 ne. then var4=var3; 3

4 Data set TEST3: Trap: Here, VAR4 was not supposed to be retained for observation #3, because VAR2 is missing. Many beginner programmers assume that BY statement automatically resets retained variables for each BY variable. But the BY statement only creates first.var and last.var, and we have to explicitly reset each BY variable. Good programming practice: Set the variables you create with the RETAIN statement to missing values (or zeros, or other suitable default values) before each iteration. The addition of this statement to the previous data step will do just what s needed: if first.var1 then var4=. ; USING RETAIN STATEMENT TO INITIALIZE VALUES You can use RETAIN statement to initialize values for individual variables, a list of variables, or members of an array. This RETAIN statement retains the values of five variables and sets their initial values to 1: retain month1-month5 1; Trap: If you don t initialize a retained variable and use it only in the RETAIN statement, this variable is not written to a data set, and the SAS log will state that the variable is uninitialized. USAGE OF IF AND WHERE STATEMENTS WITH RETAIN STATEMENT Let s continue with the previous example, where we wanted to retain the value of VAR3 in the (VAR1, VAR2) combination, provided that VAR2 is not missing. The data set is Data set TEST1: But this time, if VAR2 is missing, we want to retain the value of VAL3 from the next observation. In our example, for VAR1=2, we want to retain the value of VAR3 = 25. If we use the IF statement, we get an incorrect result: 4

5 data test2; set test1; if var2 ne.; by var1 var2; retain var4; if first.var1 then var4=.; if first.var1 then var4=var3; Data set TEST2: Why was the value of 22 erroneously retained? Trap: Conditions in the IF statement are applied after the data enters the program data vector. Good Programming Practice: Use the WHERE statement instead of IF. Conditions in the WHERE statement are applied before the data enters the input buffer, and we get the correct result: Data set TEST2: RENAME, KEEP, DROP If you need to use the DROP, KEEP and RENAME statements or DROP=, KEEP=, RENAME= options in the same data step, keep in mind that they follow a special timing rule. DROP is evaluated first, followed by KEEP and then RENAME. 1. RENAME, KEEP, DROP STATEMENTS The following code will run with errors: data test1; old_var=1; data test2; set test1 (keep=new_var /* using new variable name here will produce errors */ rename=(old_var=new_var)); SAS Log: ERROR: Variable old_var is not on file WORK.TEST1. ERROR: Invalid DROP, KEEP, or RENAME option on file WORK.TEST1. 5

6 Trap: Since KEEP= option is evaluated before RENAME= option, it doesn t recognize variable new_var because it hasn t been created yet. Good Programming Practice: When RENAME= option is used, use the old variable name with KEEP= option, but in program statements use the new variable name: data test2; set test1 (keep= old_var /* use old variable name */ rename=(old_var=new_var)); if new_var=1 then other_var=2; /* use new variable name */ put new_var= other_var= ; 2. DROP, KEEP, RENAME OPTIONS If you use DROP, KEEP, RENAME statements instead of options, the same order of evaluation applies. Trap: When applying the RENAME statement, using new variable names in other statements of the same data step results in error: data test2; set test1; KEEP new_var; /* using new variable name here will produce errors */ RENAME old_var=new_var; if new_var=1 then other_var=2; /* using new variable name here will produce errors */ put old_var= / new_var= / other_var=; SAS Log: NOTE: Variable new_var is uninitialized. WARNING: The variable old_var in the DROP, KEEP, or RENAME list has never been referenced. old_var=1 new_var=. other_var=. Good Programming Practice: If you use the RENAME statement, then in other statements in the same data step use the old variable name: data test2; set test1; RENAME old_var=new_var; if old_var=1 then other_var=2; /* use OLD variable name here */ KEEP old_var other_var; /* use OLD variable name here */ put old_var= / other_var=; SAS Log: old_var=1 other_var=2 6

7 CONCATENATION When creating variables based on the values of character variables, one should consider the following peculiarities of character variables. 1. CHARACTER VARIABLES ARE CASE-SENSITIVE. Therefore, always make sure you specified the correct case. Good Programming Practice: use the UPCASE( ) function to ensure the right character case: data test; a='notes'; if UPCASE(a)='NOTES' then b=1; put b=; SAS Log: b=1 2. CHARACTER VALUES MAY HAVE LEADING AND/OR TRAILING BLANKS It s possible to see the leading blanks in the raw data sets, but trailing blanks are not easy to detect. A good way to check for leading and trailing blanks is to attach a character (a colon, for example) to the beginning and end of a character value: data _null_; var1 = ' Day '; Join1 = ':' var1 ':'; put join1 = ; SAS Log: Join1=: Day : Good Programming Practice: Use the STRIP( ) function to get rid of these blanks: data new; a=' happy b-day '; b=strip(a); if a='happy b-day' then c=1; if STRIP(a)='happy b-day' then d=1; put c= / d=; c=. d=1 If you need to concatenate several character variables, you might have to get rid of the leading and trailing blanks, too, but instead of using STRIP( ) function for each variable, use either the CATS or CATX function. They both strip off leading and trailing blanks before concatenating strings, but with CATX, you must supply a separator for these strings. Here are the examples: 7

8 data _null_; Var1 = 'Blue '; Var2 = 'Sky '; Join1 = cats(var1,var2); Join2 = catx(' ',Var1,Var2); put Join1= / Join2= /; Join1=BlueSky Join2=Blue Sky MISSING VALUES 1. CALCULATIONS INVOLVING ARITHMETIC OPERATIONS WITH MISSING VALUES Calculations involving arithmetic operations with missing values will result in a missing value: data test; x=.; y=2; a=x+y; b=sum(x,y); put a= / b=; a=. b=2 NOTE: Missing values were generated as a result of performing an operation on missing values. Good Programming Practice: If you want to omit missing values from computations, use sample statistic functions. For example, SUM function disregards missing values. Adding X to Y using the SUM function results not in missing value but in 2. For a complete discussion and examples, see SAS Language Reference: Dictionary. 2. UNINITIALIZED VARIABLES When variable var1 is compared to a variable var2 that was not previously defined, the following condition will always be true and will produce undesirable result: data new1; age=10; if age > var1 then group='teen age'; put age= / group=; NOTE: Variable var1 is uninitialized. age=10 group=teen age 8

9 3. CHECKING FOR MISSING NUMERIC VALUES When checking for missing numeric values, the most frequently used code is the following: IF var1 =. THEN a=1; Trap: A dot is only one of the 28 ways representing a missing numeric value, and therefore in some instances, the above code won t detect all the missing values. They are the dot-underscore (._), and dot-letter(.a thru.z). Good programming practice is to pick the highest missing value from this list of 28 ways to represent a missing value, which will catch all the instances of a missing numeric value: IF var1 <=.Z THEN a=1; 4. ILLEGAL OPERATIONS According to SAS(R) 9.1 Language Reference: Concepts, SAS prints a note in the log and assigns a missing value to the result if you try to perform an illegal operation, such as the following: dividing by zero taking the logarithm of zero using an expression to produce a number too large to be represented as a floating-point number (known as overflow). The following example illustrates these points: data _null_; a=5; b=0; c = a/b; put c= ; NOTE: Division by zero detected at line 374 column 10. c=. a=5 b=0 c=. _ERROR_=1 _N_=1 NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to missing values. NUMERIC COMPARISONS When it comes to the order of numeric values, a missing numeric value comes before a non-missing numeric values, and missing numeric values have their own sort order. Therefore, the following operation produces undesirable results: data new; a=.; if a<5 then b=1; put b= ; b=1 See this paper s previous section on discussion of missing values. One of the suggested solutions was to use.z for comparisons: 9

10 data new; a=.; if.z<a<5 then b=1; put b= ; This time, the value for b is correct: b=. CONCLUSION This paper has shown the traps associated with creating variables and the ways to avoid these traps. Special attention has been given to traps involving merging data sets, comparison of numeric variables and concatenation of character variables, as well as the RETAIN statement and calculations involving missing values. Avoiding these traps will save debugging time for novice and advanced SAS programmers. REFERENCES Christof Binder (2007). Proc Format - Tricks and Traps. PhUSE 2007 Conference Proceedings SAS Institute Inc. (1999). Dealing With Numeric Representation Error in SAS Applications. Technical Support TS SAS Institute Inc., Cary North Carolina. Malachy J. Foley.(1998). MATCH-MERGING: 20 Some Traps and How to Avoid Them. SUGI 23 Conference Proceedings Malachy J. Foley (2007). MISSING VALUES: Everything You Ever Wanted to Know. WUSS 2007 Conference Proceedings Jyotheeswara Naidu Yellanki (2007). Importance of Warnings and Notes messages from SAS log. NESUG 2007 Proceedings Cody, Ron (2007). Learning SAS by Example: A Programmer s Guide. Cary, NC: SAS Institute Inc. SAS Institute Inc. (2005). SAS Language Reference: Concepts, Third Edition. Cary, NC: SAS Institute Inc. SAS Institute Inc. (2010). SAS 9.2 Language Reference: Concepts, Second Edition. Cary, NC: SAS Institute Inc. SAS Institute Inc. (2005). SAS Language Reference: Dictionary, Third Edition. Cary, NC: SAS Institute Inc. CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the author at: Olena Galligan Clinops, LLC 353 Sacramento St. San Francisco, CA stats208@gmail.com SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. indicates USA registration. Other brand and product names are trademarks of their respective companies. 10

### LOCF-Different Approaches, Same Results Using LAG Function, RETAIN Statement, and ARRAY Facility Iuliana Barbalau, ClinOps LLC. San Francisco, CA.

LOCF-Different Approaches, Same Results Using LAG Function, RETAIN Statement, and ARRAY Facility Iuliana Barbalau, ClinOps LLC. San Francisco, CA. ABSTRACT LOCF stands for Last Observation Carried Forward

### 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

### 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

### Demonstrating a DATA Step with and without a RETAIN Statement

1 The RETAIN Statement Introduction 1 Demonstrating a DATA Step with and without a RETAIN Statement 1 Generating Sequential SUBJECT Numbers Using a Retained Variable 7 Using a SUM Statement to Create SUBJECT

### Counting the Ways to Count in SAS. Imelda C. Go, South Carolina Department of Education, Columbia, SC

Paper CC 14 Counting the Ways to Count in SAS Imelda C. Go, South Carolina Department of Education, Columbia, SC ABSTRACT This paper first takes the reader through a progression of ways to count in SAS.

### 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

### The SET Statement and Beyond: Uses and Abuses of the SET Statement. S. David Riba, JADE Tech, Inc., Clearwater, FL

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.

### Custom Javascript In Planning

A Hyperion White Paper Custom Javascript In Planning Creative ways to provide custom Web forms This paper describes several of the methods that can be used to tailor Hyperion Planning Web forms. Hyperion

### Let the CAT Out of the Bag: String Concatenation in SAS 9 Joshua Horstman, Nested Loop Consulting, Indianapolis, IN

Paper S1-08-2013 Let the CAT Out of the Bag: String Concatenation in SAS 9 Joshua Horstman, Nested Loop Consulting, Indianapolis, IN ABSTRACT Are you still using TRIM, LEFT, and vertical bar operators

### 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.

### A Technique for Storing and Manipulating Incomplete Dates in a Single SAS Date Value

A Technique for Storing and Manipulating Incomplete Dates in a Single SAS Date Value John Ingersoll Introduction: This paper presents a technique for storing incomplete date values in a single variable

### 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

### Introduction to SAS Informats and Formats

CHAPTER 1 Introduction to SAS Informats and Formats 1.1 Chapter Overview... 2 1.2 Using SAS Informats... 2 1.2.1 INPUT Statement... 3 1.2.2 INPUT Function... 7 1.2.3 INPUTN and INPUTC Functions... 8 1.2.4

### 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

### 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.

### Using SAS to Build Customer Level Datasets for Predictive Modeling Scott Shockley, Cox Communications, New Orleans, Louisiana

Using SAS to Build Customer Level Datasets for Predictive Modeling Scott Shockley, Cox Communications, New Orleans, Louisiana ABSTRACT If you are using operational data to build datasets at the customer

### 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

### PharmaSUG 2015 - Paper QT26

PharmaSUG 2015 - Paper QT26 Keyboard Macros - The most magical tool you may have never heard of - You will never program the same again (It's that amazing!) Steven Black, Agility-Clinical Inc., Carlsbad,

### Using DATA Step MERGE and PROC SQL JOIN to Combine SAS Datasets Dalia C. Kahane, Westat, Rockville, MD

Using DATA Step MERGE and PROC SQL JOIN to Combine SAS Datasets Dalia C. Kahane, Westat, Rockville, MD ABSTRACT This paper demonstrates important features of combining datasets in SAS. The facility to

### Taming the PROC TRANSPOSE

Taming the PROC TRANSPOSE Matt Taylor, Carolina Analytical Consulting, LLC ABSTRACT The PROC TRANSPOSE is often misunderstood and seldom used. SAS users are unsure of the results it will give and curious

### The Program Data Vector As an Aid to DATA step Reasoning Marianne Whitlock, Kennett Square, PA

PAPER IN09_05 The Program Data Vector As an Aid to DATA step Reasoning Marianne Whitlock, Kennett Square, PA ABSTRACT The SAS DATA step is easy enough for beginners to produce results quickly. You can

### Reshaping & Combining Tables Unit of analysis Combining. Assignment 4. Assignment 4 continued PHPM 672/677 2/21/2016. Kum 1

Reshaping & Combining Tables Unit of analysis Combining Reshaping set: concatenate tables (stack rows) merge: link tables (attach columns) proc summary: consolidate rows proc transpose: reshape table Hye-Chung

### Anyone Can Learn PROC TABULATE

Paper 60-27 Anyone Can Learn PROC TABULATE Lauren Haworth, Genentech, Inc., South San Francisco, CA ABSTRACT SAS Software provides hundreds of ways you can analyze your data. You can use the DATA step

### MATCH-MERGING: 20 Some Traps and How to Avoid Them. Malachy J. Foley. University of North Carolina at Chapel Hill, NC ABSTRACT

MATCH-MERGING: 20 Some Traps and How to Avoid Them Malachy J. Foley University of North Carolina at Chapel Hill, NC ABSTRACT Match-merging is a common form of combining files. Yet, it has its pitfalls.

### 1 Description of The Simpletron

Simulating The Simpletron Computer 50 points 1 Description of The Simpletron In this assignment you will write a program to simulate a fictional computer that we will call the Simpletron. As its name implies

### EXST SAS Lab Lab #4: Data input and dataset modifications

EXST SAS Lab Lab #4: Data input and dataset modifications Objectives 1. Import an EXCEL dataset. 2. Infile an external dataset (CSV file) 3. Concatenate two datasets into one 4. The PLOT statement will

### 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

### Converting Numeric Variables and Character Variables in SAS Randall Reilly; Covance Clinical Pharmacology; Madison, WI

Converting Numeric Variables and Character Variables in SAS Randall Reilly Covance Clinical Pharmacology Madison, WI INTRODUCTION This paper gives a general understanding of how to convert numeric and

### Preparing Real World Data in Excel Sheets for Statistical Analysis

Paper DM03 Preparing Real World Data in Excel Sheets for Statistical Analysis Volker Harm, Bayer Schering Pharma AG, Berlin, Germany ABSTRACT This paper collects a set of techniques of importing Excel

### Handling Missing Values in the SQL Procedure

Handling Missing Values in the SQL Procedure Danbo Yi, Abt Associates Inc., Cambridge, MA Lei Zhang, Domain Solutions Corp., Cambridge, MA ABSTRACT PROC SQL as a powerful database management tool provides

### What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be...

What is a Loop? CSC Intermediate Programming Looping A loop is a repetition control structure It causes a single statement or a group of statements to be executed repeatedly It uses a condition to control

### 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

### DBF Chapter. Note to UNIX and OS/390 Users. Import/Export Facility CHAPTER 7

97 CHAPTER 7 DBF Chapter Note to UNIX and OS/390 Users 97 Import/Export Facility 97 Understanding DBF Essentials 98 DBF Files 98 DBF File Naming Conventions 99 DBF File Data Types 99 ACCESS Procedure Data

### Tom wants to find two real numbers, a and b, that have a sum of 10 and have a product of 10. He makes this table.

Sum and Product This problem gives you the chance to: use arithmetic and algebra to represent and analyze a mathematical situation solve a quadratic equation by trial and improvement Tom wants to find

### Changing the Shape of Your Data: PROC TRANSPOSE vs. Arrays

Changing the Shape of Your Data: PROC TRANSPOSE vs. Arrays Bob Virgile Robert Virgile Associates, Inc. Overview To transpose your data (turning variables into observations or turning observations into

### 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

### 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

### How to Benchmark Your Building. Instructions for Using ENERGY STAR Portfolio Manager and Southern California Gas Company s Web Services

How to Benchmark Your Building Instructions for Using ENERGY STAR Portfolio Manager and Southern California Gas Company s Web Services This document is a quick-start guide for entering your property into

### 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

### The SAS Data step/macro Interface

Paper TS09 The SAS Data step/macro Interface Lawrence Heaton-Wright, Quintiles, Bracknell, Berkshire, UK ABSTRACT The SAS macro facility is an extremely useful part of the SAS System. However, macro variables

### Using the COMPUTE Block in PROC REPORT Jack Hamilton, Kaiser Foundation Health Plan, Oakland, California

Using the COMPUTE Block in PROC REPORT Jack Hamilton, Kaiser Foundation Health Plan, Oakland, California ABSTRACT COMPUTE blocks add a great deal of power to PROC REPORT by allowing programmatic changes

### 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

### Data Cleaning and Base SAS Functions Caroline Bahler, Meridian Software Inc

Data Cleaning and Base SAS s Caroline Bahler, Meridian Software Inc Introduction s are small programming subroutines and can be defined as the work horses of any data cleansing operation. Dirty data, unfortunately,

### 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

Directions for the AP Invoice Upload Spreadsheet The AP Invoice Upload Spreadsheet is used to enter Accounts Payable historical invoices (only, no GL Entry) to the OGSQL system. This spreadsheet is designed

### Grade 7/8 Math Circles Sequences and Series

Faculty of Mathematics Waterloo, Ontario N2L 3G1 Centre for Education in Mathematics and Computing Grade 7/8 Math Circles Sequences and Series November 30, 2012 What are sequences? A sequence is an ordered

### 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

### 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

### Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

Binary Representation The basis of all digital data is binary representation. Binary - means two 1, 0 True, False Hot, Cold On, Off We must be able to handle more than just values for real world problems

### We can express this in decimal notation (in contrast to the underline notation we have been using) as follows: 9081 + 900b + 90c = 9001 + 100c + 10b

In this session, we ll learn how to solve problems related to place value. This is one of the fundamental concepts in arithmetic, something every elementary and middle school mathematics teacher should

### Innovative Techniques and Tools to Detect Data Quality Problems

Paper DM05 Innovative Techniques and Tools to Detect Data Quality Problems Hong Qi and Allan Glaser Merck & Co., Inc., Upper Gwynnedd, PA ABSTRACT High quality data are essential for accurate and meaningful

### Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 04 Digital Logic II May, I before starting the today s lecture

### Session 7 Fractions and Decimals

Key Terms in This Session Session 7 Fractions and Decimals Previously Introduced prime number rational numbers New in This Session period repeating decimal terminating decimal Introduction In this session,

### What You re Missing About Missing Values

Paper 1440-2014 What You re Missing About Missing Values Christopher J. Bost, MDRC, New York, NY ABSTRACT Do you know everything you need to know about missing values? Do you know how to assign a missing

### 6 3 4 9 = 6 10 + 3 10 + 4 10 + 9 10

Lesson The Binary Number System. Why Binary? The number system that you are familiar with, that you use every day, is the decimal number system, also commonly referred to as the base- system. When you

### 14:440:127 Introduction to Computers for Engineers. Notes for Lecture 06

14:440:127 Introduction to Computers for Engineers Notes for Lecture 06 Rutgers University, Spring 2010 Instructor- Blase E. Ur 1 Loop Examples 1.1 Example- Sum Primes Let s say we wanted to sum all 1,

### Alternatives to Merging SAS Data Sets But Be Careful

lternatives to Merging SS Data Sets ut e Careful Michael J. Wieczkowski, IMS HELTH, Plymouth Meeting, P bstract The MERGE statement in the SS programming language is a very useful tool in combining or

### 8 Square matrices continued: Determinants

8 Square matrices continued: Determinants 8. Introduction Determinants give us important information about square matrices, and, as we ll soon see, are essential for the computation of eigenvalues. You

### 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

### Data Preparation in SPSS

Data Preparation in SPSS Jamie DeCoster Center for Advanced Study of Teaching and Learning University of Virginia 350 Old Ivy Way Charlottesville, VA 22903 August 15, 2012 If you wish to cite the contents

### Integrating Data and Business Rules with a Control Data Set in SAS

Paper 3461-2015 Integrating Data and Business Rules with a Data Set in SAS Edmond Cheng, CACI International Inc. ABSTRACT In SAS software development, data specifications and process requirements can be

### Advanced MATCH-MERGING: Techniques, Tricks, and Traps

Advanced MATCH-MERGING: Techniques, Tricks, and Traps Malachy J. Foley University of North Carolina at Chapel Hill, NC ABSTRACT Match-merging, or BY merging, is the most common merging technique used in

### 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,

### COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

Binary numbers The reason humans represent numbers using decimal (the ten digits from 0,1,... 9) is that we have ten fingers. There is no other reason than that. There is nothing special otherwise about

### Expert Reference Series of White Papers. Binary and IP Address Basics of Subnetting

Expert Reference Series of White Papers Binary and IP Address Basics of Subnetting 1-800-COURSES www.globalknowledge.com Binary and IP Address Basics of Subnetting Alan Thomas, CCNA, CCSI, Global Knowledge

### 3.GETTING STARTED WITH ORACLE8i

Oracle For Beginners Page : 1 3.GETTING STARTED WITH ORACLE8i Creating a table Datatypes Displaying table definition using DESCRIBE Inserting rows into a table Selecting rows from a table Editing SQL buffer

### Integrity Constraints and Audit Trails Working Together Gary Franklin, SAS Institute Inc., Austin, TX Art Jensen, SAS Institute Inc.

Paper 8-25 Integrity Constraints and Audit Trails Working Together Gary Franklin, SAS Institute Inc., Austin, TX Art Jensen, SAS Institute Inc., Englewood, CO ABSTRACT New features in Version 7 and Version

### PROC REPORT: How To Get Started

PROC REPORT: How To Get Started Malachy J. Foley University of North Carolina at Chapel Hill, NC ABSTRACT PROC REPORT started as a soupped-up version of PROC PRINT. Now this unique product combines features

### A Method for Cleaning Clinical Trial Analysis Data Sets

A Method for Cleaning Clinical Trial Analysis Data Sets Carol R. Vaughn, Bridgewater Crossings, NJ ABSTRACT This paper presents a method for using SAS software to search SAS programs in selected directories

### 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.

### 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

### Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6

Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6 Number Systems No course on programming would be complete without a discussion of the Hexadecimal (Hex) number

### 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,

### An automatic predictive datamining tool. Data Preparation Propensity to Buy v1.05

An automatic predictive datamining tool Data Preparation Propensity to Buy v1.05 Januray 2011 Page 2 of 11 Data preparation - Introduction If you are using The Intelligent Mining Machine (TIMi) inside

### THE POWER OF PROC FORMAT

THE POWER OF PROC FORMAT Jonas V. Bilenas, Chase Manhattan Bank, New York, NY ABSTRACT The FORMAT procedure in SAS is a very powerful and productive tool. Yet many beginning programmers rarely make use

### Preserving Line Breaks When Exporting to Excel Nelson Lee, Genentech, South San Francisco, CA

PharmaSUG 2014 Paper CC07 Preserving Line Breaks When Exporting to Excel Nelson Lee, Genentech, South San Francisco, CA ABSTRACT Do you have imported data with line breaks and want to export the data to

### 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

### CHAPTER 5 Round-off errors

CHAPTER 5 Round-off errors In the two previous chapters we have seen how numbers can be represented in the binary numeral system and how this is the basis for representing numbers in computers. Since any

### Excel for Mac Text Functions

[Type here] Excel for Mac Text Functions HOW TO CLEAN UP TEXT IN A FLASH This document looks at some of the tools available in Excel 2008 and Excel 2011 for manipulating text. Last updated 16 th July 2015

### Intellect Platform - Parent-Child relationship Basic Expense Management System - A103

Intellect Platform - Parent-Child relationship Basic Expense Management System - A103 Interneer, Inc. Updated 2/29/2012 Created by Erika Keresztyen Fahey 2 Parent-Child relationship - A103 - Basic Expense

### 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

### 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

### 1 Checking Values of Character Variables

1 Checking Values of Character Variables Introduction 1 Using PROC FREQ to List Values 1 Description of the Raw Data File PATIENTS.TXT 2 Using a DATA Step to Check for Invalid Values 7 Describing the VERIFY,

Operators Lecture 2 Mathcad Basics + Addition, - Subtraction, * Multiplication, / Division, ^ Power ( ) Specify evaluation order Order of Operations ( ) ^ highest level, first priority * / next priority

ACADEMIC TECHNOLOGY SUPPORT Microsoft Excel: Formulas ats@etsu.edu 439-8611 www.etsu.edu/ats Table of Contents: Overview... 1 Objectives... 1 1. How to Create Formulas... 2 2. Naming Ranges... 5 3. Common

A New Paradigm for Synchronous State Machine Design in Verilog Randy Nuss Copyright 1999 Idea Consulting Introduction Synchronous State Machines are one of the most common building blocks in modern digital

### containing Kendall correlations; and the OUTH = option will create a data set containing Hoeffding statistics.

Getting Correlations Using PROC CORR Correlation analysis provides a method to measure the strength of a linear relationship between two numeric variables. PROC CORR can be used to compute Pearson product-moment

### SAS Macro Programming for Beginners

Paper 243-29 SAS Macro Programming for Beginners Susan J. Slaughter, Avocet Solutions, Davis, CA Lora D. Delwiche, Delwiche Consulting, Winters, CA ABSTRACT Macro programming is generally considered an

### Multiplying and Dividing Signed Numbers. Finding the Product of Two Signed Numbers. (a) (3)( 4) ( 4) ( 4) ( 4) 12 (b) (4)( 5) ( 5) ( 5) ( 5) ( 5) 20

SECTION.4 Multiplying and Dividing Signed Numbers.4 OBJECTIVES 1. Multiply signed numbers 2. Use the commutative property of multiplication 3. Use the associative property of multiplication 4. Divide signed

### Lies My Calculator and Computer Told Me

Lies My Calculator and Computer Told Me 2 LIES MY CALCULATOR AND COMPUTER TOLD ME Lies My Calculator and Computer Told Me See Section.4 for a discussion of graphing calculators and computers with graphing

### Introduction to Character String Functions

Introduction to Character String Functions Jason Ford, Bureau of Labor Statistics ABSTRACT Character string functions allow a user to manipulate character variables in a variety of ways. Users can create

### White Paper. Blindfolded SQL Injection

White Paper In the past few years, SQL Injection attacks have been on the rise. The increase in the number of Database based applications, combined with various publications that explain the problem and

Directions for the Well Allocation Deck Upload spreadsheet OGSQL gives users the ability to import Well Allocation Deck information from a text file. The Well Allocation Deck Upload has 3 tabs that must

### 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

### Eliminating Tedium by Building Applications that Use SQL Generated SAS Code Segments

Eliminating Tedium by Building Applications that Use SQL Generated SAS Code Segments David A. Mabey, Reader s Digest Association Inc., Pleasantville, NY ABSTRACT When SAS applications are driven by data-generated