Creating your own currency format in SAS
Formats are a great way to enhance the appearance of your data and SAS has a rich library of currency formats you can use to change the appearance of numeric values. For example, looking at the cars table below, we can apply a currency format to the invoice column so that it is more descriptive.
To do this, we issue the following format statement in the proc print step:
proc print data=cars; format invoice dollar8.2; run;
Which gives the output below :
Now imagine you are asked to apply the Rand or Kenyan Shilling format to the invoice column. There is an already existing but hard to remember Rand format in SAS (NLMNLZAR) and I have been unsuccessful in locating the Kenyan Shilling format.
To create the two formats, I use the proc format step with two picture statements to create each of the custom currency formats:
proc format ; picture ZAR 0 - high = '00,000,000,000,009.99 ' (mult=100 prefix='R'); picture KSH 0 - high = '00,000,000,000,009.99 ' (mult=100 prefix='KSh'); run;
I now apply the newly created formats to the cars data set
proc print data=cars; format invoice ZAR.; run; proc print data=cars; formatHo invoice KSH.; run;
And this is the output below for each of the reports
Hope this tutorial was useful. Happy Friday and Happy SAS'ing !
Thanks for this !!!
ISTQB Certified | Software Test Analyst
4 年Thank you for the post, AS I am new to SAS and I have been self learning this is very helpful.