From the course: SAS® 9.4 Cert Prep: Part 10 Manipulating Data with Functions
Unlock this course with a free trial
Join today to access over 22,600 courses taught by industry experts.
Converting character values to numeric values - SAS Tutorial
From the course: SAS® 9.4 Cert Prep: Part 10 Manipulating Data with Functions
Converting character values to numeric values
- [Instructor] Let's start by looking at the input function. Suppose you have a table with a Date column that is defined as character, and you want to be able to do calculations on the date. You can use the input function to do this conversion. The input function has two arguments. The first argument is the source, or the column that needs to be converted. The second argument is the informat. The informat tells SAS how the data in the input table is displayed so it knows how to read it in. Here's some examples of character values, the informat that you could specify to read the value in, and the resulting numeric value. For the width, you must specify a value that accommodates all the characters in the value you want to convert. When the character value includes a decimal point, you do not need to specify a decimal value in the informat to return a numeric value with a decimal point in the same position. If you use a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Handling column type35s
-
(Locked)
Converting column type1m 18s
-
(Locked)
Converting character values to numeric values1m 33s
-
(Locked)
Using a generic informat to read dates1m 33s
-
(Locked)
Converting the type of an existing column1m 46s
-
(Locked)
Converting numeric values to character values1m 2s
-
Demo: Using the INPUT function to convert column types7m 9s
-
(Locked)
Demo: Using the PUT function to convert column types3m 38s
-
(Locked)