₿ Bitcoin SAS Format - $bitcoin.

For Bitcoin denominated reports, a Bitcoin SAS Format will align the decimal place and display the appropriate currency symbol.  Unicode released the dedicated Bitcoin symbol (  - u20BF) in June 2017.

Btc unicode

But how many decimal places should be shown? Well, the smallest unit of Bitcoin is a Satoshi (one hundred millionth of a Bitcoin) - which is 8 places to the right of the decimal point. Interestingly, the fact that Bitcoin supply is limited (to 21 million bitcoins) means we also know the maximum size! And so the following format can be applied:

%let xbt=%sysfunc(unicode(\u20BF)); proc format; picture bitcoin low - <0 = “00,000,001.11111111” (prefix=”&xbt-”) 0 - high = “00,000,001.11111111” (prefix=”&xbt ”) ; run;

Applying this to some raw data:

Screen Shot 2018 03 18 at 22 40 54 1 300x117

displays: Screen Shot 2018 03 18 at 22 42 32

Of course, using this approach, we can quickly adjust to other cryptocurrencies.  So what about an Ethereum SAS format?  The smallest unit of Ether is a Wei.  1000000000000000000 Wei = 1 Ether.  This is a very large, small number!  Vitalik Buterin  (founder of Ethereum) suggests a more appropriate measure (eg for micropayments) would be the “Finney” (1000th of an ETH).  We’ll show balances down to the Finney, but denominated in ETH.

The agreed upon unicode symbol for ETH is  Ξ(u039E).  With a small tweak we can now have an Ethereum SAS Format:

%let eth=%sysfunc(unicode(\u039E)); proc format; picture ethereum low - <0 = ‘000,001.111’ (prefix=”&eth-”) 0 - high = ‘000,001.111’ (prefix=”&eth ”) ; run;

Our new ethereum. format will display SAS output as follows:

Screen Shot 2018 03 18 at 23 03 25

Of course, this format can easily be extended to any currency (such as Rupees, in the SO question that inspired this post).

Have fun with SAS formats. If you think you know your stuff - you can test your skills in the formats tag on Sasensei!