<?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 Drop columns if their labels are listed in another data table. in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Drop-columns-if-their-labels-are-listed-in-another-data-table/m-p/351948#M23203</link>
    <description>&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Have:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
	input make $ mpg rep78;
cards;
AMC 22 3
;
run;

data sample2;
set sample;
label	rep78	= "Please drop me"
		mpg	= "Keep me in the dataset"
		make	= "ignore me";
run;

data reference;
	input label_dropped $char32.;
cards;
Please drop me
ignore me
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Want:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;drop columns 'rep78' and 'make' in dataset 'sample2', because their labels are listed in the dataset 'reference' (column 'label_dropped').&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to achieve this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Apr 2017 23:22:02 GMT</pubDate>
    <dc:creator>ayin</dc:creator>
    <dc:date>2017-04-20T23:22:02Z</dc:date>
    <item>
      <title>Drop columns if their labels are listed in another data table.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Drop-columns-if-their-labels-are-listed-in-another-data-table/m-p/351948#M23203</link>
      <description>&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Have:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
	input make $ mpg rep78;
cards;
AMC 22 3
;
run;

data sample2;
set sample;
label	rep78	= "Please drop me"
		mpg	= "Keep me in the dataset"
		make	= "ignore me";
run;

data reference;
	input label_dropped $char32.;
cards;
Please drop me
ignore me
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Want:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;drop columns 'rep78' and 'make' in dataset 'sample2', because their labels are listed in the dataset 'reference' (column 'label_dropped').&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to achieve this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 23:22:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Drop-columns-if-their-labels-are-listed-in-another-data-table/m-p/351948#M23203</guid>
      <dc:creator>ayin</dc:creator>
      <dc:date>2017-04-20T23:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: Drop columns if their labels are listed in another data table.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Drop-columns-if-their-labels-are-listed-in-another-data-table/m-p/351955#M23205</link>
      <description>&lt;P&gt;Use SASHELP.VCOLUMN to retrieve the variables with same labels and then add them to a DROP statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ideally you can do the drop via PROC DATASETS or SQL so you don't have to recreate the entire table. I'm not sure that possible though.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 23:53:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Drop-columns-if-their-labels-are-listed-in-another-data-table/m-p/351955#M23205</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-20T23:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Drop columns if their labels are listed in another data table.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Drop-columns-if-their-labels-are-listed-in-another-data-table/m-p/351959#M23206</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%global droplist;

%macro test;
proc sql;
create table table as
select name, label from sashelp.vcolumn
	where libname = 'WORK' and memname = 'SAMPLE2';

create table table2 as
	select * from table a
	right join reference b
	on b.label_dropped = a.label;

select name into :droplist separated by ' '
from table2;

quit;
%mend test;
%test;

data sample_final;
set sample;

drop &amp;amp;droplist;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Codes are not perfect.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 00:17:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Drop-columns-if-their-labels-are-listed-in-another-data-table/m-p/351959#M23206</guid>
      <dc:creator>ayin</dc:creator>
      <dc:date>2017-04-21T00:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: Drop columns if their labels are listed in another data table.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Drop-columns-if-their-labels-are-listed-in-another-data-table/m-p/351966#M23208</link>
      <description>&lt;P&gt;Nice work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can combine the SQL steps, just make sure that you account for case differences as well. This is untested but hopefully gives you the idea of what to do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table table as
select name into : droplist separated by " " 
from sashelp.vcolumn
	where libname = 'WORK' and memname = 'SAMPLE2' and upper(label) in (select upper(label_dropped) from reference);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Apr 2017 01:11:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Drop-columns-if-their-labels-are-listed-in-another-data-table/m-p/351966#M23208</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-21T01:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: Drop columns if their labels are listed in another data table.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Drop-columns-if-their-labels-are-listed-in-another-data-table/m-p/351967#M23209</link>
      <description>&lt;P&gt;edit:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select name into : droplist separated by " " 
from sashelp.vcolumn
	where libname = 'WORK' and memname = 'SAMPLE2' and upper(label) in (select upper(label_dropped) from reference);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Apr 2017 01:23:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Drop-columns-if-their-labels-are-listed-in-another-data-table/m-p/351967#M23209</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-21T01:23:51Z</dc:date>
    </item>
  </channel>
</rss>

