Thanks for your reply Chris - I'll try to provide more details. Firstly, the encoding of my SAS session is Latin1. My issue specifically was parsing Scandinavian letters ('æ, ø, å') when getting data from a REST API. For instance, for the word 'Løft' the 'ø' character in DI studio gets converted to 'øf'. So, this is not what I want or expect - as ideally the letters 'æ, ø, å' would be preserved in words containing these letters. While typing out this reply I actually managed to get it to work; the solution was to set up the code in the following manner which is exactly like the solution offered in this thread https://communities.sas.com/t5/SAS-Programming/Encoding-when-reading-data-from-api/td-p/426050 - previously I missed the first filename definition. /*Workaround to parse special scandinavian characters*/
%let f_path = /fakepath./keyword.json;
filename lcode "&f_path";
/*Make Get Call*/
%macro getSugg();
proc http
url="https://fakepath/constant"
method="GET"
out=lcode;
headers
'Content-Type' = 'application/json'
'Accept' = 'application/json'
'Authorization' = "Bearer &access_token.";
run;
%let f_path = /fakepath./keyword.json;
filename lcode "&f_path" encoding = "utf-8";
%let f_path = /fakepath/keyword1.json;
filename lcode1 "&f_path" encoding="wlatin1";
data _null_;
infile lcode;
file lcode1;
input;
put _infile_;
run;
%parseRoot();
%parseCONSTANTTYPE();
%mend;
/*Macro to parse root*/
%macro parseRoot();
libname resp json fileref = lcode1;
data temp1;
set resp.Root;
run;
%mend;
%macro parseCONSTANTTYPE();
libname resp json fileref = lcode1;
data temp2;
set resp.CONSTANTTYPE;
where ConstantTypeName Like 'XYZ%';
run;
%mend;
%getSugg();
/*Join respons from REST API*/
proc sql;
CREATE TABLE &_output1 as
SELECT ConstantTypeName, ConstantValue
FROM temp1 as t1 inner join temp2 as t2
ON t1.ordinal_root = t2.ordinal_root
ORDER BY CConstantTypeName;
quit; Big thanks to @rudfaden
... View more