Search the site...

SASCRUNCH TRAINING
  • Home
  • Member's Area
  • How to Start
  • SAS Interface
  • Creating a Data Set
  • Practical SAS Training Course
  • SAS Base Certification Training Course
  • Proc SQL Course
  • Introduction to Time Series Analysis
  • SAS Project Training Course
  • Full Training / Membership
  • Sign up
  • About us
  • Contact us
  • Home
  • Member's Area
  • How to Start
  • SAS Interface
  • Creating a Data Set
  • Practical SAS Training Course
  • SAS Base Certification Training Course
  • Proc SQL Course
  • Introduction to Time Series Analysis
  • SAS Project Training Course
  • Full Training / Membership
  • Sign up
  • About us
  • Contact us
Sentry Page Protection
Please Wait...
Variable Attributes [10-17]


Comma. and Dollar. Format
The (Comma.) and (Dollar.) formats display the value with the comma separator and the dollar sign ($).

Example
Picture

Again, let's take a look at Num1 and Num2.

Example: (Comma.)

Data WD1;
Set Num;
Format Num2 Comma.;
Run;
Picture

The (Comma.) format displays the comma separator.

E.g. 12345.67 --> 12,346

However, the decimal places are gone!

In order to display the decimal places, you must use the CommaW.D format.

Example (Comma9.2)

Data WD2;
Set Num;
Format Num2 Comma9.2;
Run;
Picture

Two decimal places are displayed.

Please note that you need the width (W) of 9 to display the full value since the comma also counts as 1 digit.
Picture
E.g. Data = 12,345.67

  • 12     = 2 digits
  • ,      = 1 digit
  • 345    = 3 digits
  • .(dot) = 1 digit
  • 67     = 2 digits

In total, you need a minimum width of 9 to display the full value.


Let's take a look at another example.

Example (DollarW.D)

Data WD3;
Set Num;
Format Num2 Dollar10.2;
Run;
Picture

The (Dollar10.2) format displays the comma separator as well as the dollar sign ($) at before the dollar amount.

E.g. 12345.67 --> $12,346


Again, you need to add 1 extra digit to the width (W) since the dollar sign ($) takes up 1 digit as well.
Picture

​In total, you need a minimum width of 10 to display the full value.

Exercise

Copy and run the TRANSAC data set from the yellow box below.

The sales tax is 14.75%.

Create a new variable that computes the total after tax:

Total(After tax) = Total(Before tax) x 14.75%

Display the after-tax total at 2 decimal places.
Next

Need some help? 

Get Hint
Get Solution

Fill out my online form.

Already a member? Go to member's area.