Rounding Your Formats
Creating reports that show monetary values is one of the most common tasks that any organisation needs to perform when it comes to prepare a report. SAS comes with multiple pre-defined formats and the ability to generate custom ones.
When it comes to create your own format, PICTURE formats are one of the most flexible methods a programmer can use to define how data should be presented. Two very useful options that are available when customising monetary values are ROUND and MULT.
The ROUND option will round the values prior to applying the format. And the MULT option allows the programmer to specify a multiplying factor that will also be applied prior to displaying the format.
The following code divides by a thousand and round values using a picture format:
proc format; picture fmtround (round) low-high ='009k' (mult=0.001); run; data picturef; set sashelp.shoes; format_sales=put(sales,fmtround.); run; proc print data=picturef nobs; var product sales format_sales; run;
And in the results we can see the unformatted and formatted values:
format_ Product sales sales Boot $29,761 30k Men's Casual $67,242 67k Men's Dress $76,793 77k Sandal $62,819 63k Slipper $68,641 69k Sport Shoe $1,690 2k Women's Casual $51,541 52k Women's Dress $108,942 109k Boot $21,297 21k Men's Casual $63,206 63k Men's Dress $123,743 124k Sandal $29,198 29k Slipper $64,891 65k Sport Shoe $2,617 3k Women's Dress $90,648 91k Boot $4,846 5k