Or even
If 100 <= TVBudget < 200 then TVSpend = 'Medium'; else
Another approach is to create a custom format such as
Proc format;
value tvspend
. = 'Missing'
low - <100 = 'Low'
100 -< 200 = 'Medium'
200 - High = 'High'
;
And use the format with the numeric value:
proc freq ;
tables tvbudget;
format tvbudget tvspend.;
run;
Advantages:
1) I you need to create a different grouping or change boundaries just modify the Proc Format code or create a new format as needed
2) values will likely sort more consistently, as is "High" will come before "Low" or "Medium" when using character variables.
3) if you have multiple variables that would use the same boundaries you simply use the same format, no need for additional variables generally.
4) you don't have to address variable length issues that sometimes arise when your first character value is shorter than others and you get truncated values because you did not explicitly set a length for the target variable(s).
Most of the analysis and graphic procedures will honor groups created by proc format.
... View more