<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Extracting column values into a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628280#M185624</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/291284"&gt;@nicwoyak&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The vagueness was somewhat purposeful. I have asked this question with all the details before and was provided with a fairly complex but similarly case to pattern match from and didn't get a good sense of how it would work from a fundamental level.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The values are lat longs from a table of locations. The lat longs will go into the URL for a proc http request to a Google Distance Matrix API.&amp;nbsp;&lt;SPAN&gt;The requests would end up having a format like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc http&lt;BR /&gt;url="&amp;lt; https:// base url here &amp;gt; /&amp;nbsp;&amp;amp;origins=lat1,long1|lat2,long2|...|latn,longn&amp;amp;destinations=lat1,long1|lat2,long2|...|latm,longm &amp;amp;key=&amp;lt;API_Key&amp;nbsp;&amp;gt;"&lt;BR /&gt;out=resp;&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would know how long each lat long would be and I know that there's a limit around 8000 characters on the length of the url for any request.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I like it! Thanks for the answer!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A SAS variable has a limit of over 32000 characters, so you should be fine!&lt;/P&gt;</description>
    <pubDate>Fri, 28 Feb 2020 17:38:32 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-02-28T17:38:32Z</dc:date>
    <item>
      <title>Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628254#M185604</link>
      <description>&lt;P&gt;New SAS user here. I have a column in a table that I would like to get the values out of and put into a character or varchar type variable. Not separate variables, but I would want to append the values onto the end of the varchar variable each time with a designated separator. So for example I have table...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ColumnA&lt;/P&gt;&lt;P&gt;value1&lt;/P&gt;&lt;P&gt;value2&lt;/P&gt;&lt;P&gt;value3&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;valuen&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and this would end up in a variable as "value1|value2|value3|...|valuen"&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 16:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628254#M185604</guid>
      <dc:creator>nicwoyak</dc:creator>
      <dc:date>2020-02-28T16:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628259#M185609</link>
      <description>&lt;P&gt;You could transpose the data set, and in the result, concatenate all the strings. CAUTION: this won't work if the original data set has a huge number of rows as there is a maximum length that a character string can be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=have_t;
    var columna;
run;
data want;
    set have_t;
    newvar=catx('|',of col:);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;May I ask why you are doing this, as I'm having trouble thinking of a reason why you would want such a string, and there may be simpler ways to obtain the results you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 16:09:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628259#M185609</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-28T16:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628263#M185612</link>
      <description>&lt;P&gt;Do you know the maximum number of items that end up in that single variable? Will that number going forward ever change? What is the maximum length of any of the values that will ever occur?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to know the number of values as the length of the resulting character variable needed is : (number of variables * max length) + (number of variables -1) . That last is to account for the delimiter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And please describe how that variable is to be used. I have seen this request multiple times and I have not ever really gotten a good response other than "the boss said so". That form is extremely hard to do anything will. Such as do you need to consider:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Value1|value2 to be the same as value2|Value1????&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And it is a good idea to show an actual worked example with some values. For instance, are there any other variables in the data set? If so how would this process effect them?&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 16:13:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628263#M185612</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-02-28T16:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628265#M185614</link>
      <description>&lt;P&gt;I will be making a proc http request. I have data in columns that I need to put into that particular structure to make the request.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 16:14:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628265#M185614</guid>
      <dc:creator>nicwoyak</dc:creator>
      <dc:date>2020-02-28T16:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628276#M185621</link>
      <description>&lt;P&gt;The vagueness was somewhat purposeful. I have asked this question with all the details before and was provided with a fairly complex but similarly case to pattern match from and didn't get a good sense of how it would work from a fundamental level.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The values are lat longs from a table of locations. The lat longs will go into the URL for a proc http request to a Google Distance Matrix API.&amp;nbsp;&lt;SPAN&gt;The requests would end up having a format like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;proc http&lt;BR /&gt;url="&amp;lt; https:// base url here &amp;gt; /&amp;nbsp;&amp;amp;origins=lat1,long1|lat2,long2|...|latn,longn&amp;amp;destinations=lat1,long1|lat2,long2|...|latm,longm &amp;amp;key=&amp;lt;API_Key&amp;nbsp;&amp;gt;"&lt;BR /&gt;out=resp;&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would know how long each lat long would be and I know that there's a limit around 8000 characters on the length of the url for any request.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 16:56:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628276#M185621</guid>
      <dc:creator>nicwoyak</dc:creator>
      <dc:date>2020-02-28T16:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628280#M185624</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/291284"&gt;@nicwoyak&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The vagueness was somewhat purposeful. I have asked this question with all the details before and was provided with a fairly complex but similarly case to pattern match from and didn't get a good sense of how it would work from a fundamental level.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The values are lat longs from a table of locations. The lat longs will go into the URL for a proc http request to a Google Distance Matrix API.&amp;nbsp;&lt;SPAN&gt;The requests would end up having a format like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc http&lt;BR /&gt;url="&amp;lt; https:// base url here &amp;gt; /&amp;nbsp;&amp;amp;origins=lat1,long1|lat2,long2|...|latn,longn&amp;amp;destinations=lat1,long1|lat2,long2|...|latm,longm &amp;amp;key=&amp;lt;API_Key&amp;nbsp;&amp;gt;"&lt;BR /&gt;out=resp;&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would know how long each lat long would be and I know that there's a limit around 8000 characters on the length of the url for any request.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I like it! Thanks for the answer!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A SAS variable has a limit of over 32000 characters, so you should be fine!&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 17:38:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628280#M185624</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-28T17:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628281#M185625</link>
      <description>&lt;P&gt;I have things to the point where I've been able to construct my url variable in the correct format. Proc http expects the url as a quoted string. Do you know how I might be able to pass this variable into Proc http as a url?&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 17:43:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628281#M185625</guid>
      <dc:creator>nicwoyak</dc:creator>
      <dc:date>2020-02-28T17:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628287#M185627</link>
      <description>&lt;P&gt;To include a string inside double quotes in the PROC HTTP command, I would forget the TRANSPOSE solution above (although it matches the problem that was asked) and do something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
     select distinct columnA into :origins separated by '|' from mydataset;
quit;

proc http
url="&amp;lt; https:// base url here &amp;gt; / %nrstr(&amp;amp;)origins=&amp;amp;origins %nrstr(&amp;amp;)destinations=lat1,long1|lat2,long2|...|latm,longm %nrstr(&amp;amp;)key=&amp;lt;API_Key &amp;gt;"
out=resp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now, this doesn't account for the Destinations being different than the origins, you would have to modify that part. It also doesn't accountf or lat1,long1 separated by a comma, which is also do-able, but I'll have to think about the best way to achieve this. I'm guessing that stray spaces will also screw up the URL and so you would have to be very careful about that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is an illustration why sometimes we need to know the REAL problem and not the overly simplified problem of creating a string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 18:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628287#M185627</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-28T18:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628298#M185630</link>
      <description>&lt;P&gt;Thank you. I was hesitant to simply repeat a prior question and expect a better answer, but what you've provided makes a lot of sense.&lt;/P&gt;&lt;P&gt;There wouldn't actually be stray spaces, those are just for the legibility of the placeholder text. Handling a separate set of destinations is simple enough. The commas will be a challenge though.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 18:41:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628298#M185630</guid>
      <dc:creator>nicwoyak</dc:creator>
      <dc:date>2020-02-28T18:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628305#M185631</link>
      <description>&lt;P&gt;I have thought about the commas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a solution&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA (looks like this)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;45.289328,-70.02348&lt;/P&gt;
&lt;P&gt;48.283094,-65.039487&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you create the data this way, with latitude and longitude separated by a comma in a single variable, then the PROC SQL will find all the Lat/Lon combinations and place a vertical bar between them, leaving the commas between LAT and LON.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 20:41:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628305#M185631</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-28T20:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628331#M185641</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/291284"&gt;@nicwoyak&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The vagueness was somewhat purposeful. I have asked this question with all the details before and was provided with a fairly complex but similarly case to pattern match from and didn't get a good sense of how it would work from a fundamental level.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The values are lat longs from a table of locations. The lat longs will go into the URL for a proc http request to a Google Distance Matrix API.&amp;nbsp;&lt;SPAN&gt;The requests would end up having a format like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc http&lt;BR /&gt;url="&amp;lt; https:// base url here &amp;gt; /&amp;nbsp;&amp;amp;origins=lat1,long1|lat2,long2|...|latn,longn&amp;amp;destinations=lat1,long1|lat2,long2|...|latm,longm &amp;amp;key=&amp;lt;API_Key&amp;nbsp;&amp;gt;"&lt;BR /&gt;out=resp;&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would know how long each lat long would be and I know that there's a limit around 8000 characters on the length of the url for any request.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which is why we suggest providing explicit starting values and explicit desired output. Your original question related to single values to be appended. This adds the construction of pairing items apparently. I say apparently because you still have not provided a clear example of what your starting data actually looks like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may also want to look at the SAS Function GEODIST if the desire is to get a distance between two points. Or sequentially between a series of points.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 20:39:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628331#M185641</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-02-28T20:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628340#M185646</link>
      <description>&lt;P&gt;Here are two examples for you:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/d583cfa992bf56da51d435165b07e96a" target="_blank"&gt;https://gist.github.com/statgeek/d583cfa992bf56da51d435165b07e96a&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 20:56:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628340#M185646</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-02-28T20:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628342#M185648</link>
      <description>I feel like CALL EXECUTE would be a much better option here but the whole thing also likely needs to be wrapped in a macro because you'll need to process each response individually and you likely don't want to store all responses so you should loop it.</description>
      <pubDate>Fri, 28 Feb 2020 20:59:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628342#M185648</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-02-28T20:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628852#M185884</link>
      <description>&lt;P&gt;Thank you for the input everyone. I have come up with something that seems to accomplish what I need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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 &amp;amp;code., but a response was not received from
 the HTTP Procedure;
  %abort;
  %end;
%else %do;
  %if &amp;amp;SYS_PROCHTTP_STATUS_CODE. ne &amp;amp;code. %then %do;
   %put ERROR: Expected &amp;amp;code., but received &amp;amp;SYS_PROCHTTP_STATUS_CODE.
 &amp;amp;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(&amp;amp;)origins=&amp;amp;origins%nrstr(&amp;amp;)destinations=&amp;amp;destinations%nrstr(&amp;amp;)key=&amp;lt;API_KEY&amp;gt;"
out=resp;
run;&lt;BR /&gt;%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;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;where Location_Data1 and Location_Data2 have a column Lat_Long with data in the format&lt;/P&gt;&lt;P&gt;40.77657419,-73.87393838&lt;BR /&gt;40.75656710,-73.98876790&lt;BR /&gt;40.74172450,-73.98351730&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2020 17:48:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628852#M185884</guid>
      <dc:creator>nicwoyak</dc:creator>
      <dc:date>2020-03-02T17:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628854#M185885</link>
      <description>You never actually use that macro in your shown code...</description>
      <pubDate>Mon, 02 Mar 2020 17:45:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628854#M185885</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-03-02T17:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628862#M185889</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;data&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; concat ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=eof;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;length&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; new &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$500.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;retain&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; new ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; new=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;''&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; new=old;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;else&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; new=strip(new)||&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"|"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; || Strip(old);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; eof &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2020 18:10:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628862#M185889</guid>
      <dc:creator>manikandanms</dc:creator>
      <dc:date>2020-03-02T18:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628879#M185893</link>
      <description>&lt;P&gt;At the suggestion of others, I'll restate my initial problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two tables of location data, one origins and one destinations. One of the columns in both of these tables is lat_longs containing latitude and longitudes in the form for example:&lt;/P&gt;&lt;P&gt;40.77657419,-73.87393838&lt;BR /&gt;40.76251880,-73.98145280&lt;BR /&gt;40.77657419,-73.87393838&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use these lat-longs in a proc http call to a Google Distance Matrix API that has the url format:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;url="https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&amp;amp;origins=lat1,long1|lat2,long2|...|latn,longn&amp;amp;destinations=lat1,long1|lat2,long2|...|latn,longn&amp;amp;key=&amp;lt;API_KEY&amp;gt;"&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The individual lat-longs already are combined with a&amp;nbsp; the comma between them as desired, but we need to combine the separate lat-longs with a '|' character and then reference them in the url. Additionally, the syntax for Google's url use the "&amp;amp;" character which I now see needs to be masked during macro compilation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Building on PaigeMiller's reply, I think this code is sufficient for the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;

filename resp temp;

proc http
url="https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial/%nrstr(&amp;amp;)origins=&amp;amp;origins%nrstr(&amp;amp;)destinations=&amp;amp;destinations%nrstr(&amp;amp;)key=&amp;lt;API_KEY&amp;gt;"
out=resp;
run;

libname posts JSON fileref=resp;
title "Raw values from the JSON response";
proc datasets lib=posts; quit;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This creates tables Elements_Distance and Elements_Duration in the Posts library each with column "value" that contains the distances/durations.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2020 19:01:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628879#M185893</guid>
      <dc:creator>nicwoyak</dc:creator>
      <dc:date>2020-03-02T19:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628885#M185894</link>
      <description>&lt;P&gt;Now that I have a better idea of what I needed to ask, I went back and restated my problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is the GEODIST function an "as the crow flies" type of calculation, or does it use road networks like Google does? Additionally, even though it's called a Distance Matrix the Google API provides travel time durations as well. Does GEODIST or some other SAS function provide travel time durations too or strictly distances?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2020 19:11:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628885#M185894</guid>
      <dc:creator>nicwoyak</dc:creator>
      <dc:date>2020-03-02T19:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting column values into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628918#M185903</link>
      <description>GEODIST is geographical distance as the crow flies. &lt;BR /&gt;I don't believe it provides travel times, just distances.</description>
      <pubDate>Mon, 02 Mar 2020 20:34:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-column-values-into-a-variable/m-p/628918#M185903</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-03-02T20:34:31Z</dc:date>
    </item>
  </channel>
</rss>

