Procedure features: |
PROC
FORMAT statement option:
|
Input control data set |
|
Data set: |
WORK.POINTS, created from data lines in the sample code. |
|
This example shows how to create a format from a SAS data
set.
Tasks include the following:
|
options nodate pageno=1 linesize=80 pagesize=60; |
|
data scale;
input begin $ 1-2 end $ 5-8 amount $ 10-12;
datalines;
0 3 0%
4 6 3%
7 8 6%
9 10 8%
11 16 10%
; |
|
data ctrl;
length label $ 11; |
|
set scale(rename=(begin=start amount=label)) end=last; |
|
retain fmtname 'PercentageFormat' type 'n'; |
|
output; |
|
if last then do;
hlo='O';
label='***ERROR***';
output;
end;
run; |
|
proc print data=ctrl noobs; |
|
title 'The CTRL Data Set';
run; |
|
The CTRL Data Set 1
label start end fmtname type hlo
0% 0 3 PercentageFormat n
3% 4 6 PercentageFormat n
6% 7 8 PercentageFormat n
8% 9 10 PercentageFormat n
10% 11 16 PercentageFormat n
***ERROR*** 11 16 PercentageFormat n O
| |
|
proc format library=work cntlin=ctrl;
run; |
|
proc format;
invalue evaluation 'O'=4
'S'=3
'E'=2
'C'=1
'N'=0;
run; |
|
data points;
input EmployeeId $ (Q1-Q4) (evaluation.,+1);
TotalPoints=q1+q2+q3+q4;
datalines;
2355 S O O S
5889 2 . 2 2
3878 C E E E
4409 0 1 1 1
3985 3 3 3 2
0740 S E E S
2398 E E C
5162 C C C E
4421 3 2 2 2
7385 C C C N
; |
|
proc report data=work.points nowd headskip split='#';
column employeeid totalpoints totalpoints=Pctage;
define employeeid / right;
define totalpoints / 'Total#Points' right;
define pctage / format=PercentageFormat12. 'Percentage' left;
title 'The Percentage of Salary for Calculating Bonus';
run; |
The Percentage of Salary for Calculating Bonus 1
Employee Total
Id Points Percentage
2355 14 10%
5889 . ***ERROR***
3878 7 6%
4409 3 0%
3985 11 10%
0740 10 8%
2398 . ***ERROR***
5162 5 3%
4421 9 8%
7385 3 0%
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.