<?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 Proc Import statements not working: range, getnames in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-statements-not-working-range-getnames/m-p/351094#M23129</link>
    <description>&lt;P&gt;Have an excel sheet looks like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;0         1        2      ...
Col_A   Col_B   Col_C     ...
1         A               ...
          C     word      ...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want to use row 2 as variable/column names (A2:CQ2);&lt;/P&gt;&lt;P&gt;data is from the range: A3:CQ77.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Codes I was using to import the sheet:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile = "&amp;amp;_filepath&amp;amp;_fileprefix&amp;amp;_filesuffix"
						out =  work.RefTable
						replace
						dbms= xlsx;
						sheet= 'Sheet Test'n;
						range="A2:CQ77";
						getnames=yes;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However it still picked up row 1 as column names, and still picked up all the data outside the range specified (A2:CQ77).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to fix it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Apr 2017 01:01:43 GMT</pubDate>
    <dc:creator>ayin</dc:creator>
    <dc:date>2017-04-19T01:01:43Z</dc:date>
    <item>
      <title>Proc Import statements not working: range, getnames</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-statements-not-working-range-getnames/m-p/351094#M23129</link>
      <description>&lt;P&gt;Have an excel sheet looks like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;0         1        2      ...
Col_A   Col_B   Col_C     ...
1         A               ...
          C     word      ...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want to use row 2 as variable/column names (A2:CQ2);&lt;/P&gt;&lt;P&gt;data is from the range: A3:CQ77.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Codes I was using to import the sheet:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile = "&amp;amp;_filepath&amp;amp;_fileprefix&amp;amp;_filesuffix"
						out =  work.RefTable
						replace
						dbms= xlsx;
						sheet= 'Sheet Test'n;
						range="A2:CQ77";
						getnames=yes;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However it still picked up row 1 as column names, and still picked up all the data outside the range specified (A2:CQ77).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to fix it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2017 01:01:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-statements-not-working-range-getnames/m-p/351094#M23129</guid>
      <dc:creator>ayin</dc:creator>
      <dc:date>2017-04-19T01:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import statements not working: range, getnames</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-statements-not-working-range-getnames/m-p/351096#M23130</link>
      <description>&lt;P&gt;I think you might need to put the sheetname into the range?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input (A B C) ($);
cards;
Col_A   Col_B   Col_C     ...
1         A               ...
.         C     word 
;

%let path=%sysfunc(pathname(work));
libname out xlsx "&amp;amp;path\sample.xlsx";
data out.test; set have; run;
libname out clear ;

proc import datafile="&amp;amp;path\sample.xlsx"
 out=test replace
dbms=xlsx
;
range='test$::A2:C4';
 getnames=yes;
run;
proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt; Obs    Col_A    Col_B    Col_C
   1       1        A      ...
   2                C      word
&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Apr 2017 01:11:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-statements-not-working-range-getnames/m-p/351096#M23130</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-19T01:11:54Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import statements not working: range, getnames</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-statements-not-working-range-getnames/m-p/351107#M23131</link>
      <description>&lt;DIV class="xis-paraSimple"&gt;Two possibly relevant sections from the documentation.&lt;/DIV&gt;
&lt;DIV class="xis-paraSimple"&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/acpcref/69731/HTML/default/viewer.htm#n0msy4hy1so0ren1acm90iijxn8j.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/acpcref/69731/HTML/default/viewer.htm#n0msy4hy1so0ren1acm90iijxn8j.htm&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV class="xis-paraSimple"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="xis-paraSimple"&gt;&lt;U&gt;Documentation:&lt;/U&gt;&lt;/DIV&gt;
&lt;DIV id="n13febxwjyji88n1by1jeaduqrq5" class="xis-paraSimple"&gt;&lt;STRONG&gt;You can use RANGE= to specify the row number where PROC IMPORT starts to read data. Set the end point to&amp;nbsp;&lt;CODE class="xis-codeDefaultStyle"&gt;“0”&lt;/CODE&gt;, and the code then determines the last row and last column. Specify RANGE="&lt;SPAN class="xis-userSuppliedValue"&gt;Sheetname&lt;/SPAN&gt;$A#:0"; where&amp;nbsp;&lt;SPAN class="xis-userSuppliedValue"&gt;#&lt;/SPAN&gt;&amp;nbsp;is the first data row.&lt;/STRONG&gt; Thus,&amp;nbsp;&lt;CODE class="xis-codeDefaultStyle"&gt;RANGE="sheet1$A3:0";&lt;/CODE&gt;&amp;nbsp;starts to read the data at row 3. If you use RANGE= for this purpose, do not specify the DATAROW= statement.&lt;/DIV&gt;
&lt;DIV id="p1apo2pepnj6j1n1vtx0t2lfiuqo" class="xis-paraSimple"&gt;If GETNAMES=YES is set, the first row of data in the range is used for the column names, and the data starts from the second row in the range. If GETNAMES=NO is set, the data starts from the first row and column names are generated by the IMPORT procedure.&lt;/DIV&gt;
&lt;DIV id="p05ac2klj6b920n0zphz4hi0dv9o" class="xis-paraSimple"&gt;You can use the DATASETS procedure to list the SAS data set names that are mapped to the&amp;nbsp;&lt;SPAN class="xis-userSuppliedValue"&gt;range-names&lt;/SPAN&gt;. If the displayed&amp;nbsp;&lt;SPAN class="xis-userSuppliedValue"&gt;range-name&lt;/SPAN&gt;&amp;nbsp;contains single quotation marks, keep the single quotation marks as part of the&amp;nbsp;&lt;SPAN class="xis-userSuppliedValue"&gt;range-name&lt;/SPAN&gt;&amp;nbsp;to access the sheet, and enclose the entire name in double quotation marks.&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="n1os48osjjxi9sn1nwswqyu5d7k9" class="xis-paraSimple"&gt;The following examples demonstrate the use of RANGE=.&lt;/DIV&gt;
&lt;DIV class="xis-listUnordered"&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV id="p0qmo3ajcqx29pn1w7q62l7n4k3o" class="xis-item"&gt;
&lt;DIV id="n03krcjwo5g2ion17weyhbb6pxmv" class="xis-paraSimpleFirst"&gt;To retrieve data from the worksheet for two separate sheet names,&amp;nbsp;&lt;CODE class="xis-codeDefaultStyle"&gt;'My#Test$'&lt;/CODE&gt;&amp;nbsp;and&amp;nbsp;&lt;SPAN class="xis-nobr"&gt;&lt;CODE class="xis-codeDefaultStyle"&gt;' CustomerOrders'&lt;/CODE&gt;&lt;/SPAN&gt;, use one RANGE= statement in each PROC IMPORT step. Only one RANGE= statement is used in a PROC IMPORT step. Note that the name must be enclosed in quotation marks:&amp;nbsp;&lt;/DIV&gt;
&lt;PRE class="xis-codeFragment"&gt;RANGE="'My#Test$'";
 &lt;/PRE&gt;
&lt;DIV id="n059a6t1fh4czqn1p3b2v7aoqq5b" class="xis-note"&gt;&lt;SPAN class="xis-noteGenText"&gt;Note:&amp;nbsp;&lt;/SPAN&gt;If you want to read data from two ranges in the same Excel workbook file, two PROC IMPORT steps must be submitted.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV id="p00l1mw31p2ff9n1kovl8ejt6nzd" class="xis-item"&gt;
&lt;DIV id="p1ie8i3i5nujcrn1cdg3mt4sj664" class="xis-paraSimpleFirst"&gt;To represent cells within Column C, Row 2, and Column F, Row 12:&amp;nbsp;&lt;CODE class="xis-codeDefaultStyle"&gt;‘C2:F12’&lt;/CODE&gt;&amp;nbsp;the colon separates the values for upper left (UL) and lower right (LR) of the range. If this statement is not specified, the IMPORT procedure reads the entire worksheet as a range.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV id="p1m5mofdinrqjan1tanwpqwcvatd" class="xis-item"&gt;
&lt;DIV id="p0w12r2c1bkcogn11otdhcl2e3xj" class="xis-paraSimpleFirst"&gt;When data is imported from an Excel file, a sheet name that is appended with a $ character is treated as a range name. The range name refers to the whole sheet;&amp;nbsp;&lt;CODE class="xis-codeDefaultStyle"&gt;RANGE="summary$a4:b20"&lt;/CODE&gt;&amp;nbsp;or&amp;nbsp;&lt;CODE class="xis-codeDefaultStyle"&gt;RANGE='summary$a4:b20’n&lt;/CODE&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV id="p0lvk9mz2v14ymn1fy7je05mv2xa" class="xis-item"&gt;
&lt;DIV id="p0cisjmyr83atmn1qgzw8ohr7erb" class="xis-paraSimpleFirst"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;If the&amp;nbsp;&lt;SPAN class="xis-userSuppliedValue"&gt;range-name&lt;/SPAN&gt;&amp;nbsp;is available, it is recommended that you use RANGE= option without the SHEET= option for the IMPORT procedure. To use the absolute range address, it is strongly recommended that you use the full range address with quotation marks. For example, specify&amp;nbsp;&lt;CODE class="xis-codeDefaultStyle"&gt;RANGE='sheet_name$A1:C7'n;&lt;/CODE&gt;. See also the&amp;nbsp;&lt;SPAN class="xis-xrefSee"&gt;&lt;A title="SHEET= statement" href="https://support.sas.com/documentation/cdl/en/acpcref/69731/HTML/default/n0msy4hy1so0ren1acm90iijxn8j.htm#p0vaeyt80dbqhan1n5b6iuqexyfe" target="_blank"&gt;SHEET=&lt;SPAN class="xis-userSuppliedValue"&gt;sheet-name&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 19 Apr 2017 02:18:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-statements-not-working-range-getnames/m-p/351107#M23131</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-19T02:18:57Z</dc:date>
    </item>
  </channel>
</rss>

