Previous Page | Next Page

Formats for NLS

Currency Representation


Overview to Currency

Currency is the medium of exchange, which is specific to a country. SAS provides formats and informats for reading and writing currency.


U.S. Dollars

The DOLLARw.d formats and informats were first introduced to read and write American currency. DOLLARw.d

Example:

$12,345.00

DOLLARXw.d also writes currency with a leading dollar sign ($), but uses a dot (.) as the thousands separator and a comma (,) as the decimal separator. The reversal of the dot and comma for currency formatting is a convention used in many European countries.

Example:

 $12.345,00

Because the dollar sign and some currency symbols used by other countries occupy the same code point location in a code page ('5B'x on EBCDIC systems and '24'x on ASCII systems), DOLLARXw.d will produce the correct currency symbol for the specified encoding.

Limitations of the DOLLAR formats and informats are:


Localized Euros

The EUROw.d formats and informats were introduced to support the euro currency that was established by the European Monetary Union (EMU), which was formed in 1999. EUROw.d

Example:

options locale=English_UnitedKingdom;
x=12345;
put x euro10.2;
run;

Output:

 e12.345,00

Limitations of the EURO formats and informats are:


Customized Currency Representations

To create a customized currency representation, you can use the FORMAT procedure. The following example shows the creation of unique formats for the Australian dollar, the Swiss franc, and the British pound. For details about the FORMAT procedure, see Base SAS Procedures Guide.

SAS Code That Customizes Currency Representations

proc format;

   picture aud low-<0='0,000,000,009.00'
               (prefix='-AU$' mult=100)
               0-high='0,000,00,009.00 '
               (prefix='AU$' mult=100);

   picture sfr low-<0='0,000,000,009.00'
               (prefix='-SFr.' mult=100)
               0-high='0,000,00,009.00 '
               (prefix='-SFr.' mult=100);

   picture bpd low-<0='0,000,000,009.00'
               (prefix='-BPd.' mult=100)
               0-high='0,000,00,009.00 '
               (prefix='BPd.' mult=100);

run;
data currency;
input aud sfr bpd 12.2;
datalines;
12345 12345 12345 
0 0 0
-12345 -12345 -12345
;

proc print data=curr noobs;
   var aud sfr ukp;
   format aud aud. sfr sfr. bpd bpd.;
   title 'Unique Currency Formats'
run;
   

[untitled graphic]

Customizing currency representations offers flexibility, but requires a programming solution.


Localized National and International Currency Representations

The NLMNYw.d and NLMNYIw.d formats and informats were introduced to represent localized currency in two forms:

Localized national currency representation

reflects the customs and conventions of the locale. National formats are specified using the NLMNYw.d formats and informats. You must also use the LOCALE= option to specify the locale when using the NLMNYw.d formats and informats.

Example:

options locale=english_UnitedStates;
data _null_;
x=12345;
put x nlmny15.2;
run;

Output:

$12,345.00
Selected national currency representations follow:
Localized National Currency Representations
LOCALE= Currency National Representation
English_UnitedStates U.S. dollars $12,345.00
French_Canada Canadian dollars 12 345,00 $
French_France French euros 12 345,00 e
French_Switzerland Swiss francs SFr. 12'345.00
German_Germany German euros 12.345,00 e
German_Luxembourg Luxembourg euros 12.345 e
Spanish_Spain Spanish pesetas 12.345,00 e
Spanish_Venezuela Venezuelan bolivars Bs12.345,00

The localized renderings show the native customs for representing currency. For example, although these selected EMU countries might use the same euro currency, their depiction of the currency varies. Whereas French_France uses no thousands separator but uses a comma as a decimal separator, German_Germany and Spanish_Spain use a dot as a thousands separator and a comma as a decimal separator.

Localized International currency representation

conforms to ISO standard 4217. International forms are specified using the NLMNYIw.d formats and informats. International forms are commonly used to show a comparison of world currencies; for example, for airline ticket, trade, and stock market pricing. You must also use the LOCALE= option to specify the locale when using the NLMNYIw.d formats and informats. The letter "I," which signifies "International," is appended to the format and informat names.

Example:

options locale=english_UnitedStates;
data _null_;
x=12345;
put x nlmnyi15.2;
run;
Output:
USD12,345.00

Selected international currency representations follow:

International Currency Representations by Locale (ISO standard 4217)
LOCALE= Currency International Representation
English_UnitedStates U.S. dollars USD12,345.00
French_Canada Canadian dollars 12,345.00 CAD
French_France French euros 12,345.00 EUR
French_Luxembourg Luxembourg euros 12,345.00 EUR
German_Germany German euros 12,345.00 EUR
German_Switzerland Swiss francs CHF 12,345.00
Spanish_Spain Spanish pesetas 12,345.00 EUR
Spanish_Venezuela Venezuelan bolivars VEB12,345.00

The international renderings also reflect native customs for representing currency. For example, although all locales use a comma as the thousands separator and a dot as the decimal separator, they vary the placement of the ISO currency code. Whereas the EMU countries put the currency code after the currency, English_UnitedStates, German_Switzerland, and Spanish_Venezuela precede the currency with the ISO code.

For a complete list of the ISO standard 4217 currency codes, see www.bsi-global.com/Technical%2BInformation/Publications/_Publications/tig90x.doc.

A primary limitation of using localized national and international currency representations is their dependence on a value for the LOCALE= system option.

Unique National and International Monetary Representations

The NLMNLISOw.d and NLMNIISOw.d formats and informats were introduced to uniquely represent each currency without having to also use the LOCALE= option to specify the locale. Each currency is specified by a unique ISO standard 4217 currency code.

Unique national monetary representation

is specified by the unique ISO currency code. National formats are specified using the NLMNLISOw.d formats and informats. In the following example, USD is the ISO currency code for American dollars.

Note:   When using the NLMNLISOw.d formats and informats, you do not use the LOCALE= option to specify the locale.   [cautionend]

Example:

data _null_;
x=12345;
put x nlmnlusd15.2;
run;

Output:

US$12,345.00
Selected unique national currency representations follow:
Unique Currency Representations by ISO Currency Code
ISO Currency Code Currency National Representation
USD U.S. dollars USD$12,345.00
CAD Canadian dollars CA$12,345.00
EUR French euros e12,345.00
CHF Swiss francs SFr.12,345.00
EUR German euros e12,345.00
EUR Luxembourg euros e12,345.00
EUR Spanish euros e12,345.00
VEB Venezuelan bolivars Not found

A currency symbol or a currency code precedes most currencies. Also used are a comma as the thousands separator and a dot as the decimal separator.

Unique international monetary representation

is specified by the unique ISO currency code. International formats are specified using the NLMNIISOw.d formats and informats. International forms are commonly used to show a comparison of world currencies; for example, for airline ticket, trade, and stock market pricing. The letter "I", which signifies "International", is appended to the format and informat names. In the following example, USD is the ISO currency code for American dollars.

Note:   When using the NLMNIISOw.d formats and informats, you do not use the LOCALE= option to specify the locale.   [cautionend]

Example:

data _null_;
x=12345;
put x nlmni15.2;
run;
Output:
USD12,345.00

Selected international currency representations follow:

International Currency Representations by ISO Currency Code
ISO Currency Code Currency International Representation
USD U.S. dollars USD12,345.00
CAD Canadian dollars CAD12,345.00
EUR French euros EUR12,345.00
CHF Swiss francs CHF12,234.00
EUR German euros EUR12,345.00
EUR Luxembourg euros EUR12,345.00
EUR Spanish euros EUR12,345.00
VEB Venezuelan bolivars Not found

The international renderings precede the currency with the appropriate ISO code. Also used are a comma as the thousands separator and a dot as the decimal separator.


Example: Representing Currency in National and International Formats

This SAS program uses the exchange rates for selected Asia-Pacific countries against the U.S. dollar. In the output, each country's currency is represented using a national and an international format.

SAS Code That Formats National and International Currency Formats

data curr;                                                                                                                         
input ex_date mmddyy. usd aud hkd jpy sgd 12.2;                                                                                         
datalines;                                                                                                                              
061704 1.00000 1.45349 7.79930 110.110 1.71900  1                                                                                          
;                                                                                                                                       
proc print data=curr noobs label;                                                                                                       
        var ex_date usd aud hkd jpy sgd;                                                                                                
        format ex_date mmddyy. usd nlmnlusd15.2 aud nlmnlaud15.2 hkd nlmnlhkd15.2                                                       
                           jpy nlmnljpy15.2 sgd nlmnlsgd15.2;  2                                                                          
        label ex_date='Date' usd="US" aud='Australia' hkd='Hong Kong'                                                                   
                             jpy='Japan' sgd='Singapore';                                                                               
        title 'Exchange Rates for Selected Asian-Pacific Countries 
          (Localized Currency Codes)';                                         
                                                                                                                                        
proc print data=curr noobs label;                                                                                                       
        var ex_date usd aud hkd jpy sgd;                                                                                                
        format ex_date mmddyy. usd nlmniusd15.2 aud nlmniaud15.2 hkd nlmnihkd15.2                                                       
                           jpy nlmnijpy15.2 sgd nlmnisgd15.2;  3                                                                          
        label ex_date='Date' usd="US" aud='Australia' hkd='Hong Kong'                                                                   
                             jpy='Japan' sgd='Singapore';                                                                               
        title 'Exchange Rates for Selected Asian-Pacific Countries 
          (International Currency Codes)';                                     
run;                   

  1. These exchange rates, which were effective June 17, 2004, are specified as data in the SAS program.

  2. These NLMNLISO formats are applied to each of the numeric data items that are specified in the INPUT statement. These formats show currencies in the appropriate national formats.

  3. These NLMNIISO formats are applied to each of the numeric data items that are specified in the INPUT statement. These formats show currencies in the appropriate international formats.

National and International Format Output

[National and International Format Output]

Previous Page | Next Page | Top of Page