Sunday, October 4, 2009

Multi-Value Ranges

This was one of my interview questions.

"How do you write a proc format for overlapping values? Can you write down the format for variable: age?"

I have pasted the same here. The multilabel option helps a user in defining format for overlapping values.

proc format;
value age(multilabel)
0 - 12 = "Children"
13 - 19 = "Teenager"
20 - 25 = "Young Adult";
0 - 19 = "Children & Teenager";
low - 25 = "Children, Teenager & Young Adult";
25 - high = "Adult";
run;

Another example:

proc format; 
value cat(multilabel)
90 - high = "90% improvement"
75 - 90 = "75% improvement"
50 - 75 = "50% improvement";
run;

The below example is different one in which the proc format is used for the usual range values...

proc format; 
value rv
120 - high = '5'
60 < 120 = '4'
35 < 60 = '3'
25 < 35 = '2
25 = '1';
run;

No comments:

Post a Comment