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:
According to this page , that a quick search found, the British pound symbol is 'A3'x in LATIN1 encoding.
WHEN a.country ='GB' THEN 'A3'x
Hello,
I think @AllanBowe can help you out.
He authored :
Cheers,
Koen
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
Below works for me with a WLATIN1 encoded session.
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.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.
Ready to level-up your skills? Choose your own adventure.