Hi,
I am still noob with Proc http commands, Could someone please help translate this R code into sas.
So far I have following However, I am not sure where to tell sas that this is "addresses" and where to mention f="pjson"
filename json_in temp;
data _null_;
file json_in;
put '{"records":[
{"attributes":{"OBJECTID":1,"Address":"500 NE Multnomah St" , "City":"Portland", "State":"Oregon","ZIP_Code":"97232"}}
]}';
run;
data _null_;
infile json_in;
input;
put _infile_;
Run;
filename resp_fl temp;
proc http url='https://server.cloud.xx.org/kpmapsinternal/rest/services/KP_GIS_Tools/USA_Geocoding_Service/GeocodeServer/geocodeAddresses'
method='POST'
out=resp_fl
ct="application/json"
in=json_in
;
Run;
data _null_;
infile resp_fl;
input;
put _infile_;
Run;
filename resp_fl clear;
filename json_in clear;
Nevermind ... i first figured our how to get it work in CURL as its lot easier and then reengineered my way to sas
options nosource mprint;
%macro test;
filename json_in temp;
data _null_;
file json_in;
put "category=&sourceCountry=&outSR=&f=pjson&addresses={""records"":[{""attributes"":{""OBJECTID"":1,""Address"":""500 NE Multnomah St"",""City"":""Portland"",""State"":""Oregon"",""ZIP_Code"":""97232""}},
{""attributes"":{""OBJECTID"":2,""Address"":""937 E Mariposa St"",""City"":""Portland"",""State"":""CA"",""ZIP_Code"":""91016""}}]}";
run;
%PUT ************* USING CURL ************;
filename test pipe "curl -i -X POST --data ""@%sysfunc(pathname(json_in))"" https://serverHostNm.cloud.xx.org/xxmapsinternal/rest/services/GIS_Tools/USA_Geocoding_Service/GeocodeServer/geocodeAddresses?";
data _null_;
infile test;
input;
put _infile_;
Run;
filename test clear;
%PUT *************USING SAS ************;
filename resp_fl temp;
filename hdrout temp;
proc http url='https://serverHostNm.cloud.xx.org/xxmapsinternal/rest/services/GIS_Tools/USA_Geocoding_Service/GeocodeServer/geocodeAddresses?'
method='POST'
out=resp_fl
/* ct="text/plain;charset=UTF-8" */
in=json_in
headerout=hdrout ;
/*headers 'Content-Type' = 'application/json'*/
;
Run;
data _null_;
infile resp_fl;
input;
put _infile_;
Run;
filename resp_fl clear;
filename hdrout clear;
%mend;
%test;
Nevermind ... i first figured our how to get it work in CURL as its lot easier and then reengineered my way to sas
options nosource mprint;
%macro test;
filename json_in temp;
data _null_;
file json_in;
put "category=&sourceCountry=&outSR=&f=pjson&addresses={""records"":[{""attributes"":{""OBJECTID"":1,""Address"":""500 NE Multnomah St"",""City"":""Portland"",""State"":""Oregon"",""ZIP_Code"":""97232""}},
{""attributes"":{""OBJECTID"":2,""Address"":""937 E Mariposa St"",""City"":""Portland"",""State"":""CA"",""ZIP_Code"":""91016""}}]}";
run;
%PUT ************* USING CURL ************;
filename test pipe "curl -i -X POST --data ""@%sysfunc(pathname(json_in))"" https://serverHostNm.cloud.xx.org/xxmapsinternal/rest/services/GIS_Tools/USA_Geocoding_Service/GeocodeServer/geocodeAddresses?";
data _null_;
infile test;
input;
put _infile_;
Run;
filename test clear;
%PUT *************USING SAS ************;
filename resp_fl temp;
filename hdrout temp;
proc http url='https://serverHostNm.cloud.xx.org/xxmapsinternal/rest/services/GIS_Tools/USA_Geocoding_Service/GeocodeServer/geocodeAddresses?'
method='POST'
out=resp_fl
/* ct="text/plain;charset=UTF-8" */
in=json_in
headerout=hdrout ;
/*headers 'Content-Type' = 'application/json'*/
;
Run;
data _null_;
infile resp_fl;
input;
put _infile_;
Run;
filename resp_fl clear;
filename hdrout clear;
%mend;
%test;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.