O'Reilly logo

Combining and Modifying SAS® Data Sets: Examples Second Edition by Michele M. Burlew

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

Example 9.1 Converting Variable Types from Character to Numeric and Vice Versa

Goal

Read the value of a character variable and write its value to a numeric variable, and vice versa.

Example Features

Featured StepDATA step
Featured Step Options and StatementsINPUT and PUT functions

Input Data Set

Data set PRELIM_RESULTS contains preliminary test results for five test takers. TESTDATE and TEST_VERSION are numeric variables. SCORE is a character variable.

                  PRELIM_RESULTS

                                           test_
      Obs     id     testdate    score    version
       1     3205       41509     9         40012
       2     3019       30109     20          103
       3     4310           .               20101
       4     4817           .     0             .
       5     4182    11032009     18          251

Resulting Data Set

Output 9.1 RECODED_RESULTS Data Set

 Example 9.1 RECODED_RESULTS test_ Obs id testdate score version 1 3205 04/15/2009 9 40012 ...

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