BookmarkSubscribeRSS Feed
nicwoyak
Obsidian | Level 7

Thank you for the input everyone. I have come up with something that seems to accomplish what I need.

 

proc sql;
     select distinct Lat_long into :origins separated by '|' from Location_Data1;
quit;

proc sql;
     select distinct Lat_long into :destinations separated by '|' from Location_Data2;
quit;

%macro prochttp_check_return(code);
%if %symexist(SYS_PROCHTTP_STATUS_CODE) ne 1 %then %do;
  %put ERROR: Expected &code., but a response was not received from
 the HTTP Procedure;
  %abort;
  %end;
%else %do;
  %if &SYS_PROCHTTP_STATUS_CODE. ne &code. %then %do;
   %put ERROR: Expected &code., but received &SYS_PROCHTTP_STATUS_CODE.
 &SYS_PROCHTTP_STATUS_PHRASE.;
   %abort;%end;
%end;
%mend;

filename resp temp;

proc http
url="https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial/%nrstr(&)origins=&origins%nrstr(&)destinations=&destinations%nrstr(&)key=<API_KEY>"
out=resp;
run;
%prochttp_check_return(200); libname posts JSON fileref=resp; title "Raw values from the JSON response"; proc datasets lib=posts; quit; proc print data=posts.alldata(obs=20); run;

where Location_Data1 and Location_Data2 have a column Lat_Long with data in the format

40.77657419,-73.87393838
40.75656710,-73.98876790
40.74172450,-73.98351730

...

Reeza
Super User
You never actually use that macro in your shown code...
manikandanms
Fluorite | Level 6

I'm not sure if this is what you try to achieve. Try below. Its simple concatenation of all values from each row and output final concatenated variable into new dataset with that variable.

 

data concat ;

set test end=eof;

length new $500.;

retain new ;

if new='' then new=old;

else new=strip(new)||"|" || Strip(old);

if eof then output ;

run;

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 18 replies
  • 8380 views
  • 2 likes
  • 5 in conversation