Search the site...

SASCRUNCH TRAINING
  • Home
  • Member's Area
  • How to Start
  • SAS Interface
  • Creating a Data Set
  • Practical SAS Training Course
  • SAS Certified Specialist Training Program
  • Proc SQL Course
  • Introduction to Time Series Analysis
  • SAS Project Training Course
  • Full Training / Membership
  • Sign up
  • About us
  • Contact us
  • Home
  • Member's Area
  • How to Start
  • SAS Interface
  • Creating a Data Set
  • Practical SAS Training Course
  • SAS Certified Specialist Training Program
  • Proc SQL Course
  • Introduction to Time Series Analysis
  • SAS Project Training Course
  • Full Training / Membership
  • Sign up
  • About us
  • Contact us
SAS Functions [1-14]
(Samples)



Mathematical Operators

Let's start with something simple.

Below is the NUMBERS data set.


It contains 2 variables: VAL1 and VAL2. 
Picture

Note: the yellow box below contains the code for the NUMBERS data set.

Copy and run the code to get the NUMBERS data set on SAS Studio.

To add, subtract, multiply and divide values in SAS, you can use the following mathematical operators:

Add & Subtract

Data Math1;
    Set Numbers;
    val3 = val1 + val2;
    val4 = val1 - val2;

Run;
Picture

Multiplication & Division

Data Math2;
    Set Numbers;
    val3 = val1 * val2;
    val4 = val1 / val2;

Run;
Picture

Exercise

Copy and run the ACCOUNTING data set from the yellow box below. 
Picture

ACCOUNTING contains 4 variables:

EmployeeID: ID
Base: Base Salary
OTHours: Overtime Hours
Rate: Overtime Rate


Employee's salary is calculated as Base Salary + (Overtime Hours x Overtime Rate)

Write a SAS program to calculate the salary for each employee. Create any data set or variables if necessary.
Next

Need some help? 


HINT:
You must create a new variable that contains the salary information based on the equation provided.


SOLUTION:
Data EmpSalary;
Set Accounting;
Salary = Base + OTHours*Rate;
Run;

Note: The data set we created is called EMPSALARY. You do not need to follow our data set naming convention. You can name your data set any way you want. Same for the variable SALARY.


Fill out my online form.
Already a member? Go to member's area.