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: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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