BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Hundredaire
Fluorite | Level 6

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_valuesordinal_membersmember_idmember_title
11N00209Heltidsarbetande månadsavlönade, kommun, andel (%)
12N00401Utsläpp till luft av växthusgaser totalt, ton CO2-ekv/inv.
1 ACCEPTED SOLUTION

Accepted Solutions
SASJedi
SAS Super FREQ

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...

 

Check out my Jedi SAS Tricks for SAS Users

View solution in original post

3 REPLIES 3
SASJedi
SAS Super FREQ

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...

 

Check out my Jedi SAS Tricks for SAS Users
Hundredaire
Fluorite | Level 6

Sorry, its not working 😞 Also changed so that SAS session uses utf8 encoding. Any other suggestions?

Hundredaire
Fluorite | Level 6

Or it worked! 😄 Just forgot to restart sas 🙂

Thanks!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1317 views
  • 4 likes
  • 2 in conversation