BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
smijoss1
Quartz | Level 8

Hi,

I am still noob with Proc http commands, Could someone please help translate this R code into sas.

 

image.png

 

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;
1 ACCEPTED SOLUTION

Accepted Solutions
smijoss1
Quartz | Level 8

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;

View solution in original post

1 REPLY 1
smijoss1
Quartz | Level 8

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: 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
  • 1 reply
  • 532 views
  • 0 likes
  • 1 in conversation