<?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: Variable selection using two datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Variable-selection-using-two-datasets/m-p/458055#M116215</link>
    <description>&lt;P&gt;There are several methods.&amp;nbsp; The one I tend to go with is:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set small end=last;
  if _n_=1 then call execute('data new_big; set big (keep=');
  call execute(varname," ");
  if last then call execute('); run;');
run;&lt;/PRE&gt;
&lt;P&gt;This will generate the datastep to create new_big, using the big dataset, and for each row in small will add the variable to the keep list.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Apr 2018 09:25:45 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-04-27T09:25:45Z</dc:date>
    <item>
      <title>Variable selection using two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-selection-using-two-datasets/m-p/458050#M116211</link>
      <description>&lt;P&gt;Hi everyone,&lt;BR /&gt;&lt;BR /&gt;I'm relatively new to SAS and I'm struggling with this problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been given two datasets, one big table with hundreds of variables, and the other with one column containing certain variable names from the first dataset.&lt;BR /&gt;I need to select all the variables in the first dataset whose names appear in the second dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any proc or sql technique to do this?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 09:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-selection-using-two-datasets/m-p/458050#M116211</guid>
      <dc:creator>Sean100</dc:creator>
      <dc:date>2018-04-27T09:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Variable selection using two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-selection-using-two-datasets/m-p/458054#M116214</link>
      <description>&lt;P&gt;Hi, yes one way could be using the dictionnary tables:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
   select b.name into :names separated by ' '
   from sashelp.vcolumn a
   inner join
   sashelp.vcolumn b
   on a.name eq b.name
   where a.libname eq 'SASHELP'
   and a.memname eq 'AARFM'
   and b.libname eq 'SASHELP'
   and b.memname eq 'ADSMSG'
   ;
quit;
%put &amp;amp;=names.;

data adsmsg;
   set sashelp.adsmsg;
   keep &amp;amp;names.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Apr 2018 09:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-selection-using-two-datasets/m-p/458054#M116214</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2018-04-27T09:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: Variable selection using two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-selection-using-two-datasets/m-p/458055#M116215</link>
      <description>&lt;P&gt;There are several methods.&amp;nbsp; The one I tend to go with is:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set small end=last;
  if _n_=1 then call execute('data new_big; set big (keep=');
  call execute(varname," ");
  if last then call execute('); run;');
run;&lt;/PRE&gt;
&lt;P&gt;This will generate the datastep to create new_big, using the big dataset, and for each row in small will add the variable to the keep list.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 09:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-selection-using-two-datasets/m-p/458055#M116215</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-27T09:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: Variable selection using two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-selection-using-two-datasets/m-p/458062#M116218</link>
      <description>&lt;P&gt;Hi RW9,&lt;BR /&gt;&lt;BR /&gt;This looks good but I'm getting an error on the second execute routine. It says it has too many arguments.&lt;BR /&gt;&lt;BR /&gt;Any suggestions on a fix for this?&lt;BR /&gt;&lt;BR /&gt;Thanks again&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 09:38:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-selection-using-two-datasets/m-p/458062#M116218</guid>
      <dc:creator>Sean100</dc:creator>
      <dc:date>2018-04-27T09:38:46Z</dc:date>
    </item>
    <item>
      <title>Re: Variable selection using two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-selection-using-two-datasets/m-p/458063#M116219</link>
      <description>&lt;P&gt;Yes, typo there:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set small end=last;
  if _n_=1 then call execute('data new_big; set big (keep=');
  call execute(varname||" ");
  if last then call execute('); run;');
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Apr 2018 09:41:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-selection-using-two-datasets/m-p/458063#M116219</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-27T09:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: Variable selection using two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-selection-using-two-datasets/m-p/458065#M116220</link>
      <description>Thanks a million, that worked perfectly!</description>
      <pubDate>Fri, 27 Apr 2018 09:45:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-selection-using-two-datasets/m-p/458065#M116220</guid>
      <dc:creator>Sean100</dc:creator>
      <dc:date>2018-04-27T09:45:22Z</dc:date>
    </item>
  </channel>
</rss>

