<?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: Delete column whose name certain characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427470#M105432</link>
    <description>&lt;P&gt;Not easily but you can build a list of variables from either PROC CONTENTS or SASHELP.VCOLUMN which has the list of variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then include those in your DROP statement.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 13 Jan 2018 21:38:55 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-01-13T21:38:55Z</dc:date>
    <item>
      <title>Delete column whose name certain characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427469#M105431</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;I want to delete all columns that have name with string "ID" in it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My data is like that&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input abIc ID1 bxI4D b_ID2 xyzID_3; &lt;BR /&gt;cards;&lt;BR /&gt;1 2 3 4 5&lt;BR /&gt;;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I only keep&amp;nbsp;&lt;SPAN&gt;abIc and&amp;nbsp;bxI4D.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for your help.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;HC&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jan 2018 21:30:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427469#M105431</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2018-01-13T21:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column whose name certain characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427470#M105432</link>
      <description>&lt;P&gt;Not easily but you can build a list of variables from either PROC CONTENTS or SASHELP.VCOLUMN which has the list of variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then include those in your DROP statement.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jan 2018 21:38:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427470#M105432</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-13T21:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column whose name certain characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427472#M105434</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input abIc ID1 bxI4D b_ID2 xyzID_3; 
cards;
1 2 3 4 5
;run;

proc sql;
select name into :drop_list separated by ' '
from sashelp.vcolumn
where libname="WORK" and memname="HAVE" and index(name,'ID')&amp;gt;0;
quit;

%put &amp;amp;drop_list;

data have;
set have;
drop &amp;amp;drop_list;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Jan 2018 21:51:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427472#M105434</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-13T21:51:16Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column whose name certain characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427473#M105435</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input abIc ID1 bxI4D b_ID2 xyzID_3; 
cards;
1 2 3 4 5
;run;

proc sql;
select name into :drop_list separated by ','
from sashelp.vcolumn
where libname="WORK" and memname="HAVE" and index(name,'ID')&amp;gt;0;
quit;

%put &amp;amp;drop_list;

proc sql;
   alter table have
      drop  &amp;amp;drop_list;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Jan 2018 21:56:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427473#M105435</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-13T21:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column whose name certain characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427476#M105436</link>
      <description>&lt;P&gt;Thanks a lot.&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jan 2018 22:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427476#M105436</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2018-01-13T22:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column whose name certain characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427477#M105437</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Same solution as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;but, if case is irrelevant, I'd suggest using FIND function rather than INDEX function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
  input abIc id1 bxI4D b_ID2 xyzID_3; 
  cards;
1 2 3 4 5
;run;

proc sql noprint;
  select name into :drop_list separated by ' '
  from sashelp.vcolumn
    where libname="WORK" and memname="HAVE" and find(name,'ID','i');
quit;

data want;
  set have;
  drop &amp;amp;drop_list;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jan 2018 22:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427477#M105437</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-01-13T22:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column whose name certain characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427479#M105438</link>
      <description>&lt;P&gt;So weird!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS only take all letter in CAP to run that code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3291 proc sql;&lt;BR /&gt;3292 select name into :drop_list separated by ','&lt;BR /&gt;3293 from sashelp.vcolumn&lt;BR /&gt;3294 where libname="WORK" and memname="&lt;FONT color="#FF0000"&gt;myfile&lt;/FONT&gt;" and index(name,'ID')&amp;gt;0;&lt;BR /&gt;NOTE: &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;No rows were selected.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;3295 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt; real time 0.03 seconds&lt;BR /&gt; cpu time 0.03 seconds&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;3296&lt;BR /&gt;3297 proc sql;&lt;BR /&gt;3298 select name into :drop_list separated by ','&lt;BR /&gt;3299 from sashelp.vcolumn&lt;BR /&gt;3300 where libname="WORK" and memname="&lt;FONT color="#FF0000"&gt;MYFILE&lt;/FONT&gt;" and index(name,'ID')&amp;gt;0;&lt;BR /&gt;3301 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt; real time 0.03 seconds&lt;BR /&gt; cpu time 0.00 seconds&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jan 2018 22:23:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427479#M105438</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2018-01-13T22:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column whose name certain characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427480#M105439</link>
      <description>&lt;P&gt;memname is always stored as UPCASE in metadata&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jan 2018 22:25:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427480#M105439</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-13T22:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: Delete column whose name certain characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427481#M105440</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;: Maybe that's true for Windows, but not for all operating systems. That's why I suggested the find function using the 'i' modifier.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Oops! Just read your post more carefully! Yes, libname and memname have to be in upper case. However, the variable names are case sensitive on some operating systems.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jan 2018 22:37:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-column-whose-name-certain-characters/m-p/427481#M105440</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-01-13T22:37:10Z</dc:date>
    </item>
  </channel>
</rss>

