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
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.