<?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: Import row2 as variable names from excel sheet in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Import-row2-as-variable-names-from-excel-sheet/m-p/951606#M371974</link>
    <description>&lt;P&gt;Thanks for your response. There are no errors in LOG.&lt;/P&gt;
&lt;P&gt;The example posted works but when I changed the path as below &amp;amp; specifying sheet name , it's not giving desired output. I have to specify sheet name as I have multiple sheets in my excel file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  input (A B C) ($);
cards;
A B C
Name Sex Age
Alfred M 14
Alice F 13
;

filename xlsx 'C:\in\test1.xlsx';
proc export data=test file=xlsx dbms=xlsx replace;
  putnames=no;
run;

proc import datafile=test1 file=xlsx dbms=xlsx out=test2 replace;
  sheet='Sheet1';
  range='$A2:';
run;

proc print data=test2;
  title 'test2';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sri1_0-1732269263917.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/102449i84936795126D5298/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sri1_0-1732269263917.png" alt="sri1_0-1732269263917.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Nov 2024 10:02:06 GMT</pubDate>
    <dc:creator>sri1</dc:creator>
    <dc:date>2024-11-22T10:02:06Z</dc:date>
    <item>
      <title>Import row2 as variable names from excel sheet</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-row2-as-variable-names-from-excel-sheet/m-p/951517#M371947</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;I have an excel sheet like below , I want column headers in row2 as variable names of sas dataset from sheet1 .Is there anyway I can do in proc import step ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;+-------+-----------------+----------------+
   |   A   |        B        |        C       |
   +-------+-----------------+----------------+
  | SEX   |        NAME     |       AGEC     |

    +-------+-----------------+----------------+
  | M     |      Alfred     |       14       |
   | F     |      Alice      |       13       |&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried something like this&amp;nbsp; but didn't work&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc import datafile="C:\in.xlsx"&lt;BR /&gt;out=want&lt;BR /&gt;dbms=xlsx&lt;BR /&gt;replace;&lt;BR /&gt;range='$A2: ';&lt;BR /&gt;sheet='sheet1';&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Appreciate your response!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2024 16:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-row2-as-variable-names-from-excel-sheet/m-p/951517#M371947</guid>
      <dc:creator>sri1</dc:creator>
      <dc:date>2024-11-21T16:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Import row2 as variable names from excel sheet</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-row2-as-variable-names-from-excel-sheet/m-p/951530#M371948</link>
      <description>&lt;P&gt;What you posted should work.&amp;nbsp; Did you get errors in the LOG?&lt;/P&gt;
&lt;P&gt;Try this example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  input (A B C) ($);
cards;
A B C
Name Sex Age
Alfred M 14
Alice F 13
;

filename xlsx temp;
proc export data=test file=xlsx dbms=xlsx replace;
  putnames=no;
run;

proc import dbms=xlsx file=xlsx out=test1 replace;
run;

proc import dbms=xlsx file=xlsx out=test2 replace;
  range='$A2:';
run;

proc print data=test1;
  title 'test1';
run;
proc print data=test2;
  title 'test2';
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-1732211150268.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/102440iC7DB0287954A7347/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1732211150268.png" alt="Tom_0-1732211150268.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2024 17:45:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-row2-as-variable-names-from-excel-sheet/m-p/951530#M371948</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-11-21T17:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Import row2 as variable names from excel sheet</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-row2-as-variable-names-from-excel-sheet/m-p/951606#M371974</link>
      <description>&lt;P&gt;Thanks for your response. There are no errors in LOG.&lt;/P&gt;
&lt;P&gt;The example posted works but when I changed the path as below &amp;amp; specifying sheet name , it's not giving desired output. I have to specify sheet name as I have multiple sheets in my excel file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  input (A B C) ($);
cards;
A B C
Name Sex Age
Alfred M 14
Alice F 13
;

filename xlsx 'C:\in\test1.xlsx';
proc export data=test file=xlsx dbms=xlsx replace;
  putnames=no;
run;

proc import datafile=test1 file=xlsx dbms=xlsx out=test2 replace;
  sheet='Sheet1';
  range='$A2:';
run;

proc print data=test2;
  title 'test2';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sri1_0-1732269263917.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/102449i84936795126D5298/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sri1_0-1732269263917.png" alt="sri1_0-1732269263917.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2024 10:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-row2-as-variable-names-from-excel-sheet/m-p/951606#M371974</guid>
      <dc:creator>sri1</dc:creator>
      <dc:date>2024-11-22T10:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Import row2 as variable names from excel sheet</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-row2-as-variable-names-from-excel-sheet/m-p/951608#M371976</link>
      <description>&lt;P&gt;Sheet and Range are exclusive. Try:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import 
  file='C:\in\test1.xlsx' 
  dbms=xlsx 
  out=test2 
  replace;
  range='Sheet1$A2:';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Nov 2024 10:15:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-row2-as-variable-names-from-excel-sheet/m-p/951608#M371976</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-11-22T10:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: Import row2 as variable names from excel sheet</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-row2-as-variable-names-from-excel-sheet/m-p/951613#M371979</link>
      <description>&lt;P&gt;Don't use SHEET.&amp;nbsp; If you want to read from other than the FIRST sheet in the workbook then include the sheetname in the RANGE value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  range='sheet1$A2:';&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Nov 2024 12:57:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-row2-as-variable-names-from-excel-sheet/m-p/951613#M371979</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-11-22T12:57:53Z</dc:date>
    </item>
  </channel>
</rss>

