BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rishabhns
Calcite | Level 5

Hi all,

 

I need help putting in currency symbols in the salary column to the data set below:

 

data new;
input empcode salary country $;
cards;
1001 1473.33 USA
1002 1560.00 UK
1003 1646.67 india
1004 1733.33 japan
1005 1820.00 netherlands
1006 1906.67 poland
1007 1933.33 zimbabwe;
run;

 

I was told that this could be done using PROC FORMAT. The values should still be numeric, they just need the correct currency symbols. Any help is greatly appreciated

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Please explain more what you want.  If you want display the SALARY variable using the US currency symbol of a $ then you could use the DOLLAR format. No need for PROC FORMAT.

If you want to display a different symbol based on the value of COUNTRY then one format will not help since a format attached to a variable applies to every observation.  You will probably need to make a new variable that has the text.

If you want to convert the COUNTRY name into a symbol then PROC FORMAT could help.

proc format ;
  value $currency 'USA'='$' 'UK'='£' 'netherlands'='€';
run;  

You could then use that when making your new character variable.

data want;
  set new;
  length salary_display $20 ;
  salary_display=cats(put(country,$currency.),put(salary,comma12.2));
run;

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

Please explain more what you want.  If you want display the SALARY variable using the US currency symbol of a $ then you could use the DOLLAR format. No need for PROC FORMAT.

If you want to display a different symbol based on the value of COUNTRY then one format will not help since a format attached to a variable applies to every observation.  You will probably need to make a new variable that has the text.

If you want to convert the COUNTRY name into a symbol then PROC FORMAT could help.

proc format ;
  value $currency 'USA'='$' 'UK'='£' 'netherlands'='€';
run;  

You could then use that when making your new character variable.

data want;
  set new;
  length salary_display $20 ;
  salary_display=cats(put(country,$currency.),put(salary,comma12.2));
run;
andreas_lds
Jade | Level 19
What do expect as result? You can only assign one format to a variable, so displaying different currency symbols depending on the of the county-variable while maintaining numeric type is hardly possible.
rishabhns
Calcite | Level 5

The end result should look like the following

empcode    salary    Country
1001           $1473.33    USA

1002           £1560.00    UK

1003           ₹1646.67    India

 

and the rest of the symbols for their corresponding countries and currencies

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1907 views
  • 1 like
  • 3 in conversation