Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conversion to currency

Status
Not open for further replies.

sap1958

Technical User
Oct 22, 2009
138
US
data tblCustomer1;
set tblCustomer;
if Salary >= 50000 then Bonus=Salary *0.05;
if Salary <= 50000 then Bonus=Salary *0.25;
Total = Salary+Bonus ;
put Total dollar10.2;
run;

Output
Salary Bonus
23000 2357

How can I convert the Bonus from numeric to currency. I tried
put Total dollar10.2;
but no conversion
 
You can't "convert" anything to currency as there are only 2 datatypes in SAS: Numeric and Character. You can however, permanantly associate a format to display that variable as currency.

Simply replace 'put' with 'format' in your example.

Code:
data tblCustomer1;
   set tblCustomer;
   if Salary >= 50000 then Bonus=Salary *0.05;
   if Salary <= 50000 then Bonus=Salary *0.25;
   Total = Salary+Bonus ;
   format Total dollar10.2;
   run;

proc print;run;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top