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;

 

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