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
Ammonite | Level 13

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
Ammonite | Level 13

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

Our biggest data and AI event of the year.

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.

 

Register now!

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
  • 1655 views
  • 4 likes
  • 2 in conversation