BookmarkSubscribeRSS Feed
turbanator
Calcite | Level 5

I have a dataset with multiple variables. I want to show a certain value like 'less than 100k' for values less than 100k on a frequency table.

I am trying to use the following code but it is not working. Could it be because they are numerical variables and I want to make them show character values?

 

TIA

proc format;
value $Inv inventory<100000 ='Under $100k'
100000<inventory<150000 ='$100k-$150k' inventory>150000 = 'More than $150k';
value $Sale sales<100000 ='Under $100k'
100000<sales<150000 ='$100k-$150k' sales>150000 = 'More than $150k';
2 REPLIES 2
PaigeMiller
Diamond | Level 26
proc format;
    value dollarf inv 0<100000 ='Under $100k'
         100000-<150000 ='$100k-$150k' 150000-high = 'More than $150k';
    value sales 0-100000 ='Under $100k'
         100000-<150000 ='$100k-$150k' 150000-high = 'More than $150k';
run;

 

In PROC FORMAT, you specify ranges differently than you would in an IF statement. You specify the low value of the range, a dash and then the high value of the range.

 

Could it be because they are numerical variables and I want to make them show character values?

 

Not a problem, that's one of the huge benefits of PROC FORMAT is that numerical value ranges can be represented as a text string.

--
Paige Miller
ballardw
Super User

One of the other strengths of the Format for display is when multiple values are to be displayed with the exact same range descriptions only ONE format is needed.

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1062 views
  • 0 likes
  • 3 in conversation