<?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: Create a List from Column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-List-from-Column/m-p/815095#M321728</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input have $12.;
datalines;
1
2
3
4,5
6,7,8
1
;
run;

*create temporary view of data with a row for each value;
data _temp / view = _temp;
set have;

nterms= countw(have);
do i=1 to nterms;
value = scan(have, i);
output;
end;
run;

proc sql noprint;
*add all DISTINCT values into macro variable;
select distinct quote(trim(value), "'") into :var_list separated by ", " from _temp;
*drop temporary view;
*drop view _temp;
quit;


%put &amp;amp;var_list.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215179"&gt;@david27&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Team,&lt;/P&gt;
&lt;P&gt;This is what I have:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input have $12.;
datalines;
1
2
3
4,5
6,7,8
1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want all the values in single macro variable separated by comma(,)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;want='1','2','3','4','5','6','7','8'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 May 2022 19:41:02 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-05-25T19:41:02Z</dc:date>
    <item>
      <title>Create a List from Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-List-from-Column/m-p/815083#M321727</link>
      <description>&lt;P&gt;Team,&lt;/P&gt;&lt;P&gt;This is what I have:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input have $12.;
datalines;
1
2
3
4,5
6,7,8
1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want all the values in single macro variable separated by comma(,)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;want='1','2','3','4','5','6','7','8'&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 May 2022 19:24:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-List-from-Column/m-p/815083#M321727</guid>
      <dc:creator>david27</dc:creator>
      <dc:date>2022-05-25T19:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Create a List from Column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-List-from-Column/m-p/815095#M321728</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input have $12.;
datalines;
1
2
3
4,5
6,7,8
1
;
run;

*create temporary view of data with a row for each value;
data _temp / view = _temp;
set have;

nterms= countw(have);
do i=1 to nterms;
value = scan(have, i);
output;
end;
run;

proc sql noprint;
*add all DISTINCT values into macro variable;
select distinct quote(trim(value), "'") into :var_list separated by ", " from _temp;
*drop temporary view;
*drop view _temp;
quit;


%put &amp;amp;var_list.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215179"&gt;@david27&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Team,&lt;/P&gt;
&lt;P&gt;This is what I have:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input have $12.;
datalines;
1
2
3
4,5
6,7,8
1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want all the values in single macro variable separated by comma(,)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;want='1','2','3','4','5','6','7','8'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 19:41:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-List-from-Column/m-p/815095#M321728</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-05-25T19:41:02Z</dc:date>
    </item>
  </channel>
</rss>

