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.

 

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 870 views
  • 0 likes
  • 3 in conversation