Tuesday, August 26, 2008

Simple way of % Display!

-
***** DISPLAY OF PERCENTAGE IN PROC REPORT ******;

data new;
input cnt deno;
datalines;
53 54
9 -10
12 12
2 ---9
1 ---5

;
run;

data new1;
set new;
-
if cnt ne . and deno ne . then per = (cnt*100)/deno;
*cnt:COUNT, deno:DENOMINATOR, per:PERCENTAGE;
-
if (per ne 0 and per ne .) and per ne 100 then
cper = right(put(cnt,3.))IIright(put('('trim(left(put(per,4.1)))'%)',8.));
else if per eq 100 then
cper = right(put(cnt,3.))IIright(put('('trim(left(put(per,4.)))'%)',8.));
-
run;
proc print; run;

-
Together it takes a TOTAL of 11 spaces for displaying: xx (xx.x%)

3. -=> is for COUNT xxx
4.1
=> is for PERCENTAGE xx.x / 4. => is for % (if 100)
xxx
+3
=> is for SPECIAL CHARACTERS
(%)
+1
=> is for a space in b/w COUNT & PERCENTAGE
-

No comments:

Post a Comment