Specifying a format to make it meaningful

Consider the example of a management information (MI) reporting analyst based in California. The analyst will have to extract information about the sales performance of each region from the central data warehouse to present a global sales performance MI report.

Should the analyst be expected to intuitively know in which currency the revenue of each region is stored in the warehouse? It would be helpful if formats were assigned to the revenue to signify whether the local or a commonly used currency (such as the US Dollar, Yen, Euro, or British Pound) has been used to store the regional revenue figures.

The following statement, when added between the DATA and SET statements, converts the numerical index value into dollars:

FORMAT Index dollar6.2;

In the preceding snippet, the .2 represents the two decimal spaces that have been specified. 6 is the length of the format, which includes the dollar symbol. If we had specified 5.2 as the length of the format, then the output value would have been in the format 85.00 instead of $85.00. The syntax of the format is w.d, where w is the width of the format and d is the number of decimal places required. Specifying the format allows for adequate space to write the number along with the decimal specification, a period, and a negative sign. The width of the format can take up any number from 1-32. The decimal specification should be less than the width. If you don't specify a decimal specification, then the value will be written without the decimal point by default.

The following is the output that's produced after specifying the dollar format:

The syntax for some of the other currency formats is as follows:

FORMAT Index Euro7.2;/*Euro*/
FORMAT Index NLMNLGBP9.2; /*British Pound*/
FORMAT Index NLMNLJPY9.2; /*Japanese Yen*/
FORMAT Index NLMNLAUD9.2; /*Australian Dollar*/
FORMAT Index NLMNLNZD9.2; /*New Zealand Dollar*/
/*This is a comment*/;
In SAS, comments are written between '/* */ ' or, at the start of a statement, a comment can be specified by prefixing an asterisk before a statement. If prefixing an asterisk, remember to end the sentence with a semicolon, otherwise else the next statement will also be commented by default and will not execute.