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!
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.