<?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: Drop coulmns in excel when proc import in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Drop-coulmns-in-excel-when-proc-import/m-p/676436#M203958</link>
    <description>&lt;P&gt;Create a reference table that connects variable position in a dataset with the respective default Excel column name:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data excel_cols;
length name $32;
varnum = 0;
do i = 65 to 65 + 25;
  varnum + 1;
  name = byte(i);
  output;
end;
do i = 65 to 65 + 25;
  do j = 65 to 65 + 25;
    varnum + 1;
    name = byte(i) !! byte(j);
    output;
  end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will give you the names from A to ZZ (more than 700 columns, should suffice).&lt;/P&gt;
&lt;P&gt;Then you join this with the metadata of your imported table:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select d.name
  into :drop_cols separated by " "
  from dictionary.columns d right join excel_cols c
  on d.name = c.name and d.varnum = c.varnum
  where d.libname = "WORK" and d.memname="TAB1"
;
quit;

%put &amp;amp;drop_cols;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The macro variable will contain the column names of the typical "unnamed" columns in the spreadsheet. You can use it in a DROP statement or DROP= dataset option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tested this with an import of an export of sashelp.class where I removed the headers for weight and height in the spreadsheet (see attachment), and it gave me&lt;/P&gt;
&lt;PRE&gt;D E&lt;/PRE&gt;
&lt;P&gt;as result, as it should be.&lt;/P&gt;</description>
    <pubDate>Thu, 13 Aug 2020 09:57:47 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-08-13T09:57:47Z</dc:date>
    <item>
      <title>Drop coulmns in excel when proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-coulmns-in-excel-when-proc-import/m-p/676431#M203954</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;I have tried proc import with getnames=Yes|No , but couldn't find a right way do it below scenario.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When Excel column name ( A,B,C,D -n) and&amp;nbsp; variables&amp;nbsp; names (A1,B1,C1,D1-n1) are same then those columns are need to drop in sas data set output&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example: In Below screen shot of excel sheet there&amp;nbsp; are five columns (A-E) and i want in output sas data set only columns A,B and C .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output&amp;nbsp; data set variables should be&amp;nbsp; SUBJID,STUDY and DATE only&amp;nbsp;&lt;/P&gt;&lt;P&gt;this example of excel sheet, for my data excel sheet have more columns and randomly&amp;nbsp; the varibles names are same as excel columns names so need to drop the same columns when proc import&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="raja777pharma_0-1597308868052.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/48191i99C1F838860BEFBD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="raja777pharma_0-1597308868052.png" alt="raja777pharma_0-1597308868052.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Raj&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2020 08:57:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-coulmns-in-excel-when-proc-import/m-p/676431#M203954</guid>
      <dc:creator>raja777pharma</dc:creator>
      <dc:date>2020-08-13T08:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: Drop coulmns in excel when proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-coulmns-in-excel-when-proc-import/m-p/676434#M203956</link>
      <description>&lt;P&gt;Have you tried using the keep-option:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import .... data=work.import(keep=SubjId Study Date) ...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Aug 2020 09:40:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-coulmns-in-excel-when-proc-import/m-p/676434#M203956</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-08-13T09:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Drop coulmns in excel when proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-coulmns-in-excel-when-proc-import/m-p/676436#M203958</link>
      <description>&lt;P&gt;Create a reference table that connects variable position in a dataset with the respective default Excel column name:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data excel_cols;
length name $32;
varnum = 0;
do i = 65 to 65 + 25;
  varnum + 1;
  name = byte(i);
  output;
end;
do i = 65 to 65 + 25;
  do j = 65 to 65 + 25;
    varnum + 1;
    name = byte(i) !! byte(j);
    output;
  end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will give you the names from A to ZZ (more than 700 columns, should suffice).&lt;/P&gt;
&lt;P&gt;Then you join this with the metadata of your imported table:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select d.name
  into :drop_cols separated by " "
  from dictionary.columns d right join excel_cols c
  on d.name = c.name and d.varnum = c.varnum
  where d.libname = "WORK" and d.memname="TAB1"
;
quit;

%put &amp;amp;drop_cols;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The macro variable will contain the column names of the typical "unnamed" columns in the spreadsheet. You can use it in a DROP statement or DROP= dataset option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tested this with an import of an export of sashelp.class where I removed the headers for weight and height in the spreadsheet (see attachment), and it gave me&lt;/P&gt;
&lt;PRE&gt;D E&lt;/PRE&gt;
&lt;P&gt;as result, as it should be.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2020 09:57:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-coulmns-in-excel-when-proc-import/m-p/676436#M203958</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-13T09:57:47Z</dc:date>
    </item>
  </channel>
</rss>

