Example 9.4 Specifying a Numeric or Character Format at Run Time

Goal

Format the value of a variable in each observation with a format based on the value of another variable.

Example Features

Featured StepPROC FORMAT and DATA step
Featured Step Options and StatementsCATX, PUT, and PUTN functions

Input Data Set

Data set GLOBAL_REVENUE contains annual revenue results from several countries. Values from the USA and Canada are dollars. Values from Belgium, France, and Germany are euros. Values from Japan are yen.

                         GLOBAL_REVENUE

             Obs    country    year         revenue 1 USA 2008 3819501.03 2 USA 2009 -19391.88 3 USA 2010 1033.65 4 Canada 2008 471868.81 5 Canada 2009 297654.01 6 Canada 2010 111123.09 7 Belgium 2008 -1201.30 8 Belgium 2009 404019.87 9 Belgium ...

Get Combining and Modifying SAS® Data Sets: Examples Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.