FORMAT Procedure

Example 10: Filling a Picture Format

Features:
PICTURE statement options: :
FILL=
PREFIX=

Details

This example does the following:
  • prefixes the formatted value with a specified character
  • fills the leading blanks with a specified character
  • shows the interaction between the FILL= and PREFIX= options

Program

data pay;
   input Name $ MonthlySalary;
   datalines;
Liu   1259.45
Lars  1289.33
Kim   1439.02
Wendy 1675.21
Alex  1623.73
;
proc format;
   picture salary low-high='00,000,000.00' (fill='*' prefix='$');
run;
proc print data=pay noobs;
   format monthlysalary salary.;
   title 'Printing Salaries for a Check';
run;

Program Description

Create the PAY data set. The PAY data set contains the monthly salary for each employee.
data pay;
   input Name $ MonthlySalary;
   datalines;
Liu   1259.45
Lars  1289.33
Kim   1439.02
Wendy 1675.21
Alex  1623.73
;
Define the SALARY. picture format and specify how the picture will be filled. When FILL= and PREFIX= PICTURE statement options appear in the same picture, the format places the prefix and then the fill characters. The SALARY. format fills the picture with the fill character because the picture has zeros as digit selectors. The leftmost comma in the picture is replaced by the fill character.
proc format;
   picture salary low-high='00,000,000.00' (fill='*' prefix='$');
run;
Print the PAY data set. The NOOBS option suppresses the printing of observation numbers. The FORMAT statement temporarily associates the SALARY. format with the variable MonthlySalary.
proc print data=pay noobs;
   format monthlysalary salary.;
Specify the title.
   title 'Printing Salaries for a Check';
run;

Output

Printing Salaries for a Check
Printing Salaries for a Check