I download data through an api (GET method). I receive data in json. How do I decode åäö correctly in the column "member_title"? (Encoding=wlatin1).
My code:
filename test "C:\Users\......json";
proc http method="GET"
url="http://api.kolada.se/v2/kpi_groups?title=agenda 2030"
out=test;
run;
libname x json fileref=test;
proc copy in=x out=work ;
run;
The result:
ordinal_values | ordinal_members | member_id | member_title |
1 | 1 | N00209 | Heltidsarbetande månadsavlönade, kommun, andel (%) |
1 | 2 | N00401 | Utsläpp till luft av växthusgaser totalt, ton CO2-ekv/inv. |
Looks like the JSON file is UTF8 encoded, and your SAS session is not. Try this:
filename test "C:\Users\......json" encoding=utf8;
proc http
url="http://api.kolada.se/v2/kpi_groups?title=agenda 2030"
out=test
method="GET"
;
run;
libname x json fileref=test;
proc copy in=x out=work ;
run;
Does that make it work better for you? For best results, you may want to ensure your SAS session uses UTF8 encoding, too...
Looks like the JSON file is UTF8 encoded, and your SAS session is not. Try this:
filename test "C:\Users\......json" encoding=utf8;
proc http
url="http://api.kolada.se/v2/kpi_groups?title=agenda 2030"
out=test
method="GET"
;
run;
libname x json fileref=test;
proc copy in=x out=work ;
run;
Does that make it work better for you? For best results, you may want to ensure your SAS session uses UTF8 encoding, too...
Sorry, its not working 😞 Also changed so that SAS session uses utf8 encoding. Any other suggestions?
Or it worked! 😄 Just forgot to restart sas 🙂
Thanks!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.