<?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: How to choose a list of variables from a specific column and save it in a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248754#M46752</link>
    <description>&lt;P&gt;To exclude "constant" from the selection you can insert a WHERE condition into the PROC SQL step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select variable into :varlist separated by ' '
from zyz
where lowcase(variable) ne 'constant';
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To restrict the selection to variables whose names start with 'x' (case insensitive), you could use the following WHERE condition:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where lowcase(variable) eqt 'x';&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 08 Feb 2016 22:02:26 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2016-02-08T22:02:26Z</dc:date>
    <item>
      <title>How to choose a list of variables from a specific column and save it in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248732#M46740</link>
      <description>&lt;P&gt;Hi Folks, I have a dataset and need to pick up the observations ( of the first column as variable_list (say, &amp;amp;varlist).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Therefore, I want to end up with;&lt;/P&gt;&lt;P&gt;%put &amp;amp;varlist ;&lt;/P&gt;&lt;P&gt;varlist=x1 x2 x3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;would you please help me in this regard? Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data zyz;
length variable $ 4;
input variable R B C;
cards;
x1 1 2 3&amp;nbsp;
x2 5 6 7&amp;nbsp;
x3 8 9 10;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Feb 2016 20:56:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248732#M46740</guid>
      <dc:creator>Moh</dc:creator>
      <dc:date>2016-02-08T20:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose a list of variables from a specific column and save it in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248736#M46744</link>
      <description>&lt;P&gt;What do you want if any of the values of "variable" are duplicated?&lt;/P&gt;
&lt;P&gt;Does the order have to match the order in the data set?&lt;/P&gt;
&lt;P&gt;Are there any case sensitive issues to be concerned about such as values of x1 and X1 should be treated the same?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 21:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248736#M46744</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-08T21:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose a list of variables from a specific column and save it in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248738#M46746</link>
      <description>Either way, since "variable" (not a brilliant name, can cause confusion) is character you need to enclose the list values within quotes, 'x1' etc.</description>
      <pubDate>Mon, 08 Feb 2016 21:36:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248738#M46746</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-02-08T21:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose a list of variables from a specific column and save it in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248747#M46748</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67760"&gt;@Moh﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a basic approach you could try&amp;nbsp;this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select variable into :varlist separated by ' '
from zyz;
quit;

%put &amp;amp;=varlist;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If, for example, duplicates are to be eliminated, disregarding case, you could adapt the SELECT statement accordingly:&lt;BR /&gt; &lt;FONT face="courier new,courier"&gt;select distinct(lowcase(variable)) into ...&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;SPAN&gt;(This would result in a &lt;EM&gt;sorted&lt;/EM&gt; list due to the DISTINCT keyword.)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 21:47:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248747#M46748</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-08T21:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose a list of variables from a specific column and save it in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248750#M46749</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw﻿&lt;/a&gt;&lt;/P&gt;&lt;P&gt;In my case duplicated values is not possible, neither the order and case sensitive....Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 21:53:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248750#M46749</guid>
      <dc:creator>Moh</dc:creator>
      <dc:date>2016-02-08T21:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose a list of variables from a specific column and save it in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248751#M46750</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh﻿&lt;/a&gt;&amp;nbsp;for your answer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;How if one of the variables is not starting with x , for example, its name is "constant".&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I get rid of "constant"&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 21:55:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248751#M46750</guid>
      <dc:creator>Moh</dc:creator>
      <dc:date>2016-02-08T21:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose a list of variables from a specific column and save it in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248753#M46751</link>
      <description>&lt;P&gt;To exclude use WHERE&lt;/P&gt;
&lt;PRE&gt;proc sql noprint;
   select variable into :varlist separated by ' '
   from zyz
   where variable ne "constant"
;
quit;
&lt;/PRE&gt;
&lt;P&gt;The where clause could use functions to exclude values that start with a letter: where substr(variable,1,1) ne 'b'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or a list of characters where substr(variable,1,1) not in (&amp;nbsp;'b' 'c' 'q')&lt;/P&gt;
&lt;P&gt;or a lot of other ways to compare things.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 22:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248753#M46751</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-08T22:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose a list of variables from a specific column and save it in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248754#M46752</link>
      <description>&lt;P&gt;To exclude "constant" from the selection you can insert a WHERE condition into the PROC SQL step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select variable into :varlist separated by ' '
from zyz
where lowcase(variable) ne 'constant';
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To restrict the selection to variables whose names start with 'x' (case insensitive), you could use the following WHERE condition:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where lowcase(variable) eqt 'x';&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Feb 2016 22:02:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248754#M46752</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-08T22:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose a list of variables from a specific column and save it in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248755#M46753</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH﻿&lt;/a&gt;: Wouldn't quotes become a hindrance if &amp;amp;varlist was used, e.g., in a KEEP statement?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 22:06:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248755#M46753</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-08T22:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose a list of variables from a specific column and save it in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248815#M46761</link>
      <description>@freelancereinhard as the OP presents x1 X2 x3 are values in the variable variable (!). A keep statement shouldn't be relevant unless any transposing occurs. A bit hypothetical from the information we have at hand.</description>
      <pubDate>Tue, 09 Feb 2016 06:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-choose-a-list-of-variables-from-a-specific-column-and/m-p/248815#M46761</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-02-09T06:51:07Z</dc:date>
    </item>
  </channel>
</rss>

