Amadeus cookies policy - you'll see this message only once.

Amadeus use cookies on this website. They help us to know a little bit about you and how you use our website, which improves the browsing experience and marketing - both for you and for others. They are stored locally on your computer or mobile device. To accept cookies, continue browsing as normal. Or, go to the privacy policy for more information.

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);

data picturef;

proc print data=picturef nobs;
 var product sales format_sales;

And in the results we can see the unformatted and formatted values:

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