BookmarkSubscribeRSS Feed
DarrylLawrence
Obsidian | Level 7

I need to create a currency symbol, based on the country code in my customer table.

 

This is the code that I am running.

However the results for the country code "GB" results in a ? and not the £ symbol in my output table.

I used (alt + 156) to insert the £ value in the code. 

 

The character encoding for my SAS session is Latin1.

 

How can I get the £ sign to reflect in my SAS output table / results?

 

proc sql;

create table CURRENCY_VALUES as

select distinct a.country,

CASE

WHEN a.country ='BW' THEN 'P'

WHEN a.country ='GH' THEN 'C'

WHEN a.country ='LS' THEN 'L'

WHEN a.country ='NA' THEN '$'

WHEN a.country ='NG' THEN 'N'

WHEN a.country ='SZ' THEN 'E'

WHEN a.country ='ZA' THEN 'R'

WHEN a.country ='ZM' THEN 'K'

WHEN a.country ='GB' THEN "£"

WHEN a.country ='KE' THEN 'K'

WHEN a.country ='AU' THEN '$'

else ''

END as CURRENCY_SYMBOL, count(*) as Records

from

CUSTOMER_TABLE as a

group by country,

CASE

WHEN a.country ='BW' THEN 'P'

WHEN a.country ='GH' THEN 'C'

WHEN a.country ='LS' THEN 'L'

WHEN a.country ='NA' THEN '$'

WHEN a.country ='NG' THEN 'N'

WHEN a.country ='SZ' THEN 'E'

WHEN a.country ='ZA' THEN 'R'

WHEN a.country ='ZM' THEN 'K'

WHEN a.country ='GB' THEN "£"

WHEN a.country ='KE' THEN 'K'

WHEN a.country ='AU' THEN '$'

else '' end;

quit;


RESULTS:

DarrylLawrence_0-1664886017564.png

 

 



5 REPLIES 5
Tom
Super User Tom
Super User

According to this page , that a quick search found, the British pound symbol is 'A3'x in LATIN1 encoding.

Tom_0-1664888665723.png

 

WHEN a.country ='GB' THEN 'A3'x

 

sbxkoenk
SAS Super FREQ

Hello,

 

I think @AllanBowe can help you out.

 

He authored :

Cheers,

Koen

Shmuel
Garnet | Level 18

I believe it is an ENCODING system option problem.
Anyhow I typed the symbols in ms-word and copied it into sas.

Here is the log of my test USING ENCODING=UTF-8:

69         data a;
70           txt = '$ £ €';
71           put txt=;
72         run;
txt=$ £ €

checking the hexadecimal values:

$ is '24'x

£ is 'C2A3'x

€ is 'E282'x

 

Patrick
Opal | Level 21

Below works for me with a WLATIN1 encoded session.

Patrick_0-1664927880123.png

 

SASKiwi
PROC Star

It would be worthwhile checking the encoding and locale settings of your SAS session:

proc options option = locale;
run;

proc options option = encoding;
run;

I would think having ENCODING = WLATIN1 and LOCALE = EN_GB should enable easier pound sign reporting.

sas-innovate-2024.png

📢

ANNOUNCEMENT

The early bird rate has been extended! Register by March 18 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1099 views
  • 1 like
  • 6 in conversation