Hi,
I'm running a Stored Process that sometimes will take Swedish letters as an input and I'm having trouble getting sas to Decode them properly.
so I have a request that looks like this, and the idea is that ref should resolve to ÖstersundHuvudlager.
However what I get is ;
REF=>stersundHuvudlager
_ENCODING=UTF-8
_REQENCODING=UTF-8
I assume this has to do with that the sas encoding is utf-8 and the request isnt. But I'm unsure how to solve it.
When I look at your encoding using %D6 than I find that it encodes for Ö but not in UTF-8. This looks like a Latin encoding. The same character encoded using UTF-8 is %C3%96.
I found this doing this in a UTF-8 SAS session:
24 data _null_;
25 sw='Östersund';
26 swe=urlencode(sw);
27 put _all_;
28 run;
sw=Östersund swe=%C3%96stersund _ERROR_=0 _N_=1
So I would have a look at the URL.
Hope this helps,
-- Jan
Here are some suggestions:
1. Always use UTF-8 based encoding. That means that Ö is encoded as %C3%96, and not %D6.
2. Specify this option in your SAS Stored Process code to ensure that the URLENCODE/URLDECODE functions use the UTF-8 encoding/decoding method:
options urlencoding=utf8;
This sample code simulates a stored process that gives the desired result:
options urlencoding=utf8;
* Your input parameter;
%let REF=%nrstr(%%C3%%96stersundHuvudlager);
* Your decoded input parameter;
%let REF_DECODED=%sysfunc(urldecode(&REF));
%put &=REF &=REF_DECODED;
This technique should work with Unicode and non-Unicode SAS Stored Process Servers.
Vince DelGobbo
SAS R&D
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.