<?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: Importing an xlsx sheet without headers? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-an-xlsx-sheet-without-headers/m-p/847693#M335140</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/437488"&gt;@GreyBlack&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Perhaps I should rephrase; I'm hoping to add headers after performing the&lt;BR /&gt;import, but I'm not clear on how to do that.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That makes even less sense.&amp;nbsp; Once the file is imported it is a dataset.&amp;nbsp; Datasets do not have headers. The variables in a dataset have names.&amp;nbsp; If you know the names you want to use for the variables you can include that in the code using the RENAME= dataset option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import dbms=xlsx file=xlsx out=class(rename=(a=name b=sex c=age d=height e=weight)) replace;
  getnames=no;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 05 Dec 2022 00:12:22 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-12-05T00:12:22Z</dc:date>
    <item>
      <title>Importing an xlsx sheet without headers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-an-xlsx-sheet-without-headers/m-p/847689#M335137</link>
      <description>Good evening, everyone!&lt;BR /&gt;&lt;BR /&gt;So I have an xlsx file that I'm trying to import into Excel that doesn't have any column names within the actual file. I'm able to use the proc import to get the data out from the file, but it reads row 1 as the names of the columns.&lt;BR /&gt;&lt;BR /&gt;Does anyone have a way to name the columns of an xlsx data set as you're importing?&lt;BR /&gt;&lt;BR /&gt;For reference, my code right now is:&lt;BR /&gt;&lt;BR /&gt;Proc import out=data1 file='c:\filename.xlsx' dbms=xlsx;&lt;BR /&gt;Sheet="sheet1";&lt;BR /&gt;Getnames=no;&lt;BR /&gt;Run;</description>
      <pubDate>Sun, 04 Dec 2022 23:56:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-an-xlsx-sheet-without-headers/m-p/847689#M335137</guid>
      <dc:creator>GreyBlack</dc:creator>
      <dc:date>2022-12-04T23:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an xlsx sheet without headers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-an-xlsx-sheet-without-headers/m-p/847691#M335138</link>
      <description>&lt;P&gt;I do not understand what you are asking since the code you showed does import an XLSX sheet that does not have a header row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename xlsx temp;
proc export dbms=xlsx file=xlsx data=sashelp.class;
  putnames=no;
run;

proc import dbms=xlsx file=xlsx out=want replace;
  getnames=no;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1670198647244.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78007i6F9E92DFEDD0F49E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1670198647244.png" alt="Tom_0-1670198647244.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you know the names you want to use include them in the output dataset name using the RENAME= dataset option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import dbms=xlsx file=xlsx out=class(rename=(a=name b=sex c=age d=height e=weight)) replace;
  getnames=no;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Dec 2022 00:10:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-an-xlsx-sheet-without-headers/m-p/847691#M335138</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-05T00:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an xlsx sheet without headers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-an-xlsx-sheet-without-headers/m-p/847692#M335139</link>
      <description>Perhaps I should rephrase; I'm hoping to add headers after performing the&lt;BR /&gt;import, but I'm not clear on how to do that.&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Dec 2022 00:07:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-an-xlsx-sheet-without-headers/m-p/847692#M335139</guid>
      <dc:creator>GreyBlack</dc:creator>
      <dc:date>2022-12-05T00:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an xlsx sheet without headers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-an-xlsx-sheet-without-headers/m-p/847693#M335140</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/437488"&gt;@GreyBlack&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Perhaps I should rephrase; I'm hoping to add headers after performing the&lt;BR /&gt;import, but I'm not clear on how to do that.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That makes even less sense.&amp;nbsp; Once the file is imported it is a dataset.&amp;nbsp; Datasets do not have headers. The variables in a dataset have names.&amp;nbsp; If you know the names you want to use for the variables you can include that in the code using the RENAME= dataset option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import dbms=xlsx file=xlsx out=class(rename=(a=name b=sex c=age d=height e=weight)) replace;
  getnames=no;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Dec 2022 00:12:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-an-xlsx-sheet-without-headers/m-p/847693#M335140</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-05T00:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an xlsx sheet without headers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-an-xlsx-sheet-without-headers/m-p/847737#M335156</link>
      <description>&lt;P&gt;The usual remedy: save to a .csv file and read that with a DATA step, where you set all names, types and attributes without relying on the guesses of PROC IMPORT.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2022 08:13:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-an-xlsx-sheet-without-headers/m-p/847737#M335156</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-12-05T08:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an xlsx sheet without headers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-an-xlsx-sheet-without-headers/m-p/847739#M335157</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/437488"&gt;@GreyBlack&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Perhaps I should rephrase; I'm hoping to add headers after performing the&lt;BR /&gt;import, but I'm not clear on how to do that.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your variable names will be A, B, C,...&lt;/P&gt;
&lt;P&gt;If you need to rename them then use either a rename statement within a SAS datastep or if you don't need to process the data then use Proc Datasets.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below some sample code using Proc Datasets.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.imported_from_excel;
  a=1;
  b='a';
  c=99;
run;

proc datasets lib=work nolist;
  modify imported_from_excel;
    rename 
      a=myvar
      b=some_other_name
      c=new_name
      ;
  run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1670228636499.png" style="width: 497px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78023i6339F4C3F8CF688C/image-dimensions/497x87?v=v2" width="497" height="87" role="button" title="Patrick_0-1670228636499.png" alt="Patrick_0-1670228636499.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2022 08:24:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-an-xlsx-sheet-without-headers/m-p/847739#M335157</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-12-05T08:24:10Z</dc:date>
    </item>
  </channel>
</rss>

