I have numeric data i want to code a generic macro to display a range if the numeric variable value is falling in the range else if value is less or greater than range range then display '$$$'.
Asked
Active
Viewed 69 times
2 Answers
0
You should use a format to do this. Read up on defining formats with proc format
here or look at the official documentation.

user667489
- 9,501
- 2
- 24
- 35
-
@Apache11 you don't need a macro. As @user667489 suggests, create a format with `proc format`, then assign that format to the age variable. Formatted values are displayed by default, even though the underlying values are not changed – Longfish Sep 16 '16 at 07:46
0
Format depends on whether age is a numeric or character variable. I have assumed numeric here, if it is character you need to add a $.
proc format;
value age_A
0-14 = '$$$'
15-25 = '15-25'
25-high = '$$$'
;run;
If you want to use this in a proc print/freq etc then use
proc print data = ;
var age;
format age age_a.;
run;
if you want to change the data in a dataset then use the put function.
data ;
set;
new_var = put(age, age_a.);
run;

Panda
- 28
- 1
- 6