<?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: Macro for Keeping variable names containing specific string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Keeping-variable-names-containing-specific-string/m-p/384386#M92174</link>
    <description>&lt;P&gt;Single quotes prevent resolution of macro variables:&amp;nbsp; ('&amp;amp;new.')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use double quotes instead:&amp;nbsp; ("&amp;amp;new.")&lt;/P&gt;</description>
    <pubDate>Mon, 31 Jul 2017 18:50:52 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-07-31T18:50:52Z</dc:date>
    <item>
      <title>Macro for Keeping variable names containing specific string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Keeping-variable-names-containing-specific-string/m-p/384379#M92172</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have several datasets (.sas7bdat files in libname 'dataset') that I'm trying to read into my program. &amp;nbsp;I only want to keep variables that contain 'ID' in the name. I have code that does what I want it to do, but I want to put it in a macro.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;When I run the code in the macro I created, I have an issue at the&amp;nbsp;PROC SQL/%PUT part of my code and I get &lt;STRONG&gt;warning&lt;/STRONG&gt;&amp;nbsp;that says, "&lt;EM&gt;No rows selected.......no KEEP variables found, statement ignored&lt;/EM&gt;." &amp;nbsp;Thus, it reads in the datasets in but doesn't keep the variables I want. &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any&amp;nbsp;suggestions? &amp;nbsp;Thank you.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;%macro datain(old,new,final);
   data &amp;amp;new;
   set dataset.&amp;amp;old;
   run;

proc sql noprint;
select trim(compress(name))
into :keep_vars separated by ' '
from dictionary.columns
where libname = upcase('work')
and memname = upcase('&amp;amp;new.')
and upcase(name) like '%ID%';
quit;

%put &amp;amp;keep_vars.;

data &amp;amp;final;
set &amp;amp;new;
keep &amp;amp;keep_vars.;
run;
%mend datain;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Jul 2017 18:41:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Keeping-variable-names-containing-specific-string/m-p/384379#M92172</guid>
      <dc:creator>glcoolj12</dc:creator>
      <dc:date>2017-07-31T18:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Keeping variable names containing specific string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Keeping-variable-names-containing-specific-string/m-p/384384#M92173</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132054"&gt;@glcoolj12&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;I have several datasets (.sas7bdat files in libname 'dataset') that I'm trying to read into my program. &amp;nbsp;I only want to keep variables that contain 'ID' in the name. I have code that does what I want it to do, but I want to put it in a macro.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;When I run the code in the macro I created, I have an issue at the&amp;nbsp;PROC SQL/%PUT part of my code and I get &lt;STRONG&gt;warning&lt;/STRONG&gt;&amp;nbsp;that says, "&lt;EM&gt;No rows selected.......no KEEP variables found, statement ignored&lt;/EM&gt;." &amp;nbsp;Thus, it reads in the datasets in but doesn't keep the variables I want. &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Any&amp;nbsp;suggestions? &amp;nbsp;Thank you.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Really, we don't know what variables you have. This could be a completely correct result. We don't know. And we can't debug this ... unless ... you show us that you do indeed have variables with ID in the name, perhaps by showing us a PROC CONTENTS or the appropriate parts of sashelp.vcolumn.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 18:47:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Keeping-variable-names-containing-specific-string/m-p/384384#M92173</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-07-31T18:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Keeping variable names containing specific string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Keeping-variable-names-containing-specific-string/m-p/384386#M92174</link>
      <description>&lt;P&gt;Single quotes prevent resolution of macro variables:&amp;nbsp; ('&amp;amp;new.')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use double quotes instead:&amp;nbsp; ("&amp;amp;new.")&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 18:50:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Keeping-variable-names-containing-specific-string/m-p/384386#M92174</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-31T18:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for Keeping variable names containing specific string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-Keeping-variable-names-containing-specific-string/m-p/384396#M92175</link>
      <description>This fixed the issue - thank you so much!</description>
      <pubDate>Mon, 31 Jul 2017 19:07:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-Keeping-variable-names-containing-specific-string/m-p/384396#M92175</guid>
      <dc:creator>glcoolj12</dc:creator>
      <dc:date>2017-07-31T19:07:40Z</dc:date>
    </item>
  </channel>
</rss>

