O'Reilly logo

Step-by-Step Programming with Base SAS 9.4, Second Edition, 2nd Edition by SAS Institute

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Part 1, “Introduction to the SAS System”
Part 2, “Getting Your Data into Shape”
Chapter 7, “Understanding DATA Step Processing,” on page 107
About Numeric Variables in SAS
A numeric variable is a variable whose values are numbers.
Note: SAS uses double-precision floating-point representation for calculations and, by
default, for storing numeric variables in SAS data sets.
SAS accepts numbers in many forms, such as scientific notation, and hexadecimal. For
more information, see the discussion on the types of numbers that SAS can read from
data lines in SAS Language Reference: Concepts. For simplicity, this documentation
concentrates on numbers in standard representation, as shown here:
1254
336.05
-243
You can use SAS to perform all types of mathematical operations. To perform a
calculation in a DATA step, you can write an assignment statement in which the
expression contains arithmetic operators, SAS functions, or a combination of the two. To
compare numeric variables, you can write an IF-THEN/ELSE statement using logical
operators. For more information about numeric functions, see the discussion in the
“Functions and CALL Routines” section in SAS Functions and CALL Routines:
Reference.
Input SAS Data Set for Examples
Tradewinds Travel Inc. has an external file that contains information about their most
popular tours:
1 2 3 4 5
-----------------------------------
Japan 8 982 1020 Express
Greece 12 . 748 Express
New Zealand 16 1368 1539 Southsea
Ireland 7 787 628 Express
Venezuela 9 426 505 Mundial
Italy 8 852 598 Express
Russia 14 1106 1024 A-B-C
Switzerland 9 816 834 Tour2000
Australia 12 1299 1169 Southsea
Brazil 8 682 610 Almeida
The numbered fields represent
1
the name of the country toured
2
the number of nights on the tour
3
the airfare in US dollars
118 Chapter 8 Working with Numeric Variables

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required