SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Search||next

Creating Variables
Lesson Overview

 
Introduction  

Often, when working with data sets, it's useful to create completely new variables or new variables that are based on the values of existing variables. These new variables can contain the results of SAS functions, conditionally-assigned values, or running totals of other variable values.

For example, you can use the existing SAS data set Finance.Records to create a new data set that has a new variable, TotalLoan, which accumulates the total of loan payments.


SAS Data Set Finance.Records
Account Amount Rate Months Payment Code
101-1092 22000 0.1000 60 467.43 1
101-1731 114000 0.0950 360 958.57 2
101-1289 10000 0.1050 36 325.02 2
101-3144 3500 0.1050 12 308.52 1


SAS Data Set Finance.Records2
Account Amount Rate Months Payment Code TotalLoan
101-1092 22000 0.1000 60 467.43 1 467.43
101-1731 114000 0.0950 360 958.57 2 1426.00
101-1289 10000 0.1050 36 325.02 2 1751.02
101-3144 3500 0.1050 12 308.52 1 2059.54


This lesson provides a range of techniques for creating and controlling new variables. It also shows how these variables can help you to analyze your data.

This lesson contains 36 pages and takes approximately 60-90 minutes to complete.


Objectives

In this lesson, you learn to

  • create a variable by using a simple assignment statement
  • create a variable that accumulates values down observations 
  • assign values to a variable conditionally 
  • specify the lengths of new variables 
  • execute multiple statements conditionally. 


Prerequisites

Before taking this lesson, you should have completed the following lessons: 

Introduction to SAS Programming

Creating SAS Data Sets (at least one of the following)

||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement