This video series is intended to help you learn how to program using SAS for your statistical needs. Lesson 6 introduces the concept of SAS arithmetic in the DATA STEP. I discuss how one can add, subtract, divide, multiply, or create their own formulas for variables in the data. I also discuss using SAS arithmetic to create new variables based on mathematical transformations of old variables, which may sometimes aid in meeting the assumptions of statistical tests. Finally, I provide basic examples of each of these methods.
1. SAS uses many of the same arithmetic operators to add, subtract, divide and multiply as other programming languages and basic algebra.
2. Arithmetic operations on variables affect the entire list of observations. So be careful in operating with existing variables and make new variables if you can afford to.
3. The varnum ;option on the PROC CONTENTS statement can allow you to see the variables listed in the order they were created.
input x y;
proc print data=main;
data new_main; set main;
a = x + y;
b = x – y;
c = x * y;
d = x / y;
e = x ** y;
f = ((x + y) * (x – y));
proc contents data=new_main varnum;
proc print data=new_main;
“Copyright Disclaimer Under Section 107 of the Copyright Act 1976, allowance is made for “fair use” for purposes such as criticism, comment, news reporting, teaching, scholarship, and research. Fair use is a use permitted by copyright statute that might otherwise be infringing. Non-profit, educational or personal use tips the balance in favor of fair use.”
Anayansi Gamboa has an extensive background in clinical data management as well as experience with different EDC systems including Oracle InForm, InForm Architect, Central Designer, CIS, Clintrial, Medidata Rave, Central Coding, OpenClinica Open Source and Oracle Clinical.