<?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: Concat list into long string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concat-list-into-long-string/m-p/423278#M104068</link>
    <description>&lt;P&gt;Would change&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select * from applications
    where phone in (&amp;amp;PhoneString)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;into&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select * from applications
    where phone in (select phone from phoneNumbers)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 22 Dec 2017 08:30:07 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2017-12-22T08:30:07Z</dc:date>
    <item>
      <title>Concat list into long string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-list-into-long-string/m-p/423249#M104059</link>
      <description>&lt;P&gt;I'm trying to take a long list and concatenate it into a long string/list, that I can store in a macro variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For instance:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to turn a dataset with a set of phone numbers like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; Phone&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;1234567890&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp;4634069845&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp;9438758375&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp;2349853984&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp;3459086098&lt;/P&gt;&lt;P&gt;6&amp;nbsp; &amp;nbsp;6689476988&lt;/P&gt;&lt;P&gt;7&amp;nbsp; &amp;nbsp;3030495986&lt;/P&gt;&lt;P&gt;8&amp;nbsp; &amp;nbsp;3459495954&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...into a macro variable that looks like:&lt;/P&gt;&lt;P&gt;'1234567890', '4634069845', '9438758375', '2349853984', '3459086098', '6689476988', '3030495986', '3459495954'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Say we'll call it &amp;amp;PhoneString, then I can later create a sql query that looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select * from applications&lt;/P&gt;&lt;P&gt;where phone in (&amp;amp;PhoneString).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2017 02:20:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-list-into-long-string/m-p/423249#M104059</guid>
      <dc:creator>anthdelm</dc:creator>
      <dc:date>2017-12-22T02:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: Concat list into long string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-list-into-long-string/m-p/423251#M104060</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/183651"&gt;@anthdelm&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;I'm trying to take a long list and concatenate it into a long string/list, that I can store in a macro variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For instance:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to turn a dataset with a set of phone numbers like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; Phone&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;1234567890&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp;4634069845&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp;9438758375&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp;2349853984&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp;3459086098&lt;/P&gt;&lt;P&gt;6&amp;nbsp; &amp;nbsp;6689476988&lt;/P&gt;&lt;P&gt;7&amp;nbsp; &amp;nbsp;3030495986&lt;/P&gt;&lt;P&gt;8&amp;nbsp; &amp;nbsp;3459495954&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;...into a macro variable that looks like: /* look into sql into clause for creating macro vars separated by a delimiter in sas docs. the answer is in your question*/&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;'1234567890', '4634069845', '9438758375', '2349853984', '3459086098', '6689476988', '3030495986', '3459495954'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Say we'll call it &amp;amp;PhoneString, then I can later create a sql query that looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select * from applications&lt;/P&gt;&lt;P&gt;where phone in (&amp;amp;PhoneString).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2017 02:28:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-list-into-long-string/m-p/423251#M104060</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-12-22T02:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Concat list into long string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-list-into-long-string/m-p/423253#M104061</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select quote(PhoneNumber)
  into :PhoneList separated by ","
  from PhoneList;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note the macro variable PhoneList is limited to 32K characters in length.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2017 02:40:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-list-into-long-string/m-p/423253#M104061</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-12-22T02:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Concat list into long string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-list-into-long-string/m-p/423276#M104066</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cntlin;
set phone_numbers (keep=phone rename=(phone=start)) end=done;
type = 'C';
fmtname = "select_phone";
length label $10;
label = 'yes';
output;
if done
then do;
  label = 'no';
  start = '**OTHER**';
  hlo = 'O';
  output;
end;
run;

proc sql;
select * from applications where put(phone,$select_phone.) = 'yes';
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Using a format avoids problems with macro variable overflows, and creates short code even with options mprint active. Your only limit is your available memory for loading the format. And that is much higher than the 32767 of a macro variable.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2017 08:22:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-list-into-long-string/m-p/423276#M104066</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-12-22T08:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: Concat list into long string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-list-into-long-string/m-p/423277#M104067</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID Phone$;
datalines;
1 1234567890
2 4634069845
3 9438758375
4 2349853984
5 3459086098
6 6689476988
7 3030495986
8 3459495954
;

proc sql noprint;
	select quote(Phone,"'") into :PhoneNums separated by ',' from have;
run;

%put &amp;amp;PhoneNums.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Dec 2017 08:26:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-list-into-long-string/m-p/423277#M104067</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-12-22T08:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Concat list into long string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-list-into-long-string/m-p/423278#M104068</link>
      <description>&lt;P&gt;Would change&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select * from applications
    where phone in (&amp;amp;PhoneString)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;into&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select * from applications
    where phone in (select phone from phoneNumbers)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Dec 2017 08:30:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-list-into-long-string/m-p/423278#M104068</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2017-12-22T08:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Concat list into long string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-list-into-long-string/m-p/423281#M104069</link>
      <description>&lt;P&gt;Another nice solution that avoids creating an unwieldy macro variable.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2017 08:59:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-list-into-long-string/m-p/423281#M104069</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-12-22T08:59:24Z</dc:date>
    </item>
  </channel>
</rss>

