How do I get the correct encoding for this data i am retrieving form with an api? The Danish letters æ,ø,å does not show corret
filename src temp encoding="utf-8";
proc http
method="GET"
url="%nrstr(https://dawa.aws.dk/adresser?q=Ærøgade&struktur=mini&per_side=1&format=csv)"
out=src;
run;
data _null_;
infile src;
input;
put _infile_;
run;
data test ;
infile src encoding="utf-8" dlm=',' missover dsd firstobs=2 ;
length id $ 36 status $1 vejkode $4 vejnavn $20 adresseringsvejnavn $20 husnr $10 etage $10 dor $10 supplerendebynavn $10 postnr $4 postnrnavn $20 kommunekode $4 adgangsadresseid $36 x 8 y 8 ;
input id $ status $ vejkode $ vejnavn $ adresseringsvejnavn $ husnr $ etage$ dor $ supplerendebynavn $ postnr $ postnrnavn $ kommunekode $ adgangsadresseid x y;
run;
Data example
id,status,vejkode,vejnavn,adresseringsvejnavn,husnr,etage,dør,supplerendebynavn,postnr,postnrnavn ,kommunekode,adgangsadresseid,x,y 0a3f50b3-135b-32b8-e044-0003ba298018,1,0365,Ærøgade,Ærøgade,2,,,,5960,Marstal,0492,0a3f5088-8b 75-32b8-e044-0003ba298018,10.51420646,54.85857924
I found a solution. Basically you save the file with utf-8 and then open it with wlatin.
filename resp "C:\Temp\map.json";
filename minmap 'C:/Temp/gogle_distance.map';
proc http
url="https://maps.googleapis.com/maps/api/directions/json?origin=&home.%nrstr(&destination=)&work."
method= "GET"
out=resp;
run;
%** trick der gøre at JSON filen encodes med wlatin;
filename resp "C:\Temp\map.json" encoding='utf-8';
filename resp1 "C:\Temp\map1.json" encoding='wlatin1';
data _null_;
infile resp;
file resp1;
input;
put _infile_;
run;
What is your SAS session encoding? This is normally setup when SAS starts up, you would need to change it there.
That is not possible. I need a solution where the encoding is converted to my sas encoding,
I don't believe that is possible. If your SAS session is Wlatin, and the data coming in has UTF-8 or 16, which both have far more characters in their sets, then "converting" data is not possible as the wlatin charset is too small to handle it. This is what you are seeing now, where the character set just says I don't know and puts a strange symbol.
I am not talking about converting the whole charset to from utf-8 to wlatin. Only those that are in wlatin
I found a solution. Basically you save the file with utf-8 and then open it with wlatin.
filename resp "C:\Temp\map.json";
filename minmap 'C:/Temp/gogle_distance.map';
proc http
url="https://maps.googleapis.com/maps/api/directions/json?origin=&home.%nrstr(&destination=)&work."
method= "GET"
out=resp;
run;
%** trick der gøre at JSON filen encodes med wlatin;
filename resp "C:\Temp\map.json" encoding='utf-8';
filename resp1 "C:\Temp\map1.json" encoding='wlatin1';
data _null_;
infile resp;
file resp1;
input;
put _infile_;
run;
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.