<?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 xlsx file using macros about years in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/import-xlsx-file-using-macros-about-years/m-p/827227#M326754</link>
    <description>&lt;P&gt;Okay, I apologize. It's a csv file, not an xlsx file. Really my bad. End of day and I wasn't careful. Sorry.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Aug 2022 20:52:36 GMT</pubDate>
    <dc:creator>geneshackman</dc:creator>
    <dc:date>2022-08-04T20:52:36Z</dc:date>
    <item>
      <title>import xlsx file using macros about years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-xlsx-file-using-macros-about-years/m-p/827221#M326751</link>
      <description>&lt;P&gt;Hi all. I'm hoping this is a fairly simple question, I can't get the syntax quite right. Or else I'm making a simple typo that I just can't see.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let start=18; *first year;&lt;BR /&gt;%let end=%eval(&amp;amp;start+2); *end year;&lt;BR /&gt;%let start4=2018;&lt;BR /&gt;%let end4 = %eval(&amp;amp;start4+2);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc import out = pzip&amp;amp;start.&amp;amp;end &lt;BR /&gt;datafile = "\\dohfile02\phig\PHIGDATA\Data\perinatal_zips\perinzip_&amp;amp;start4._&amp;amp;end4.xlsx" &lt;BR /&gt;DBMS=XLSX REPLACE;&lt;BR /&gt;getnames = yes;&lt;BR /&gt;SHEET="PerinZIP_&amp;amp;start4._&amp;amp;end4";&lt;BR /&gt;options MSGLEVEL=i;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The exel file is named:&lt;/P&gt;
&lt;P&gt;PerinZIP_2018_2020.xlsx&lt;/P&gt;
&lt;P&gt;and the sheet I want is:&lt;/P&gt;
&lt;P&gt;PerinZIP_2018_2020&lt;/P&gt;
&lt;P&gt;In this folder&lt;/P&gt;
&lt;P&gt;\\dohfile02\phig\PHIGDATA\Data\perinatal_zips&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the error i get is generally this, "Physical file does not exist"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;316 proc import out = pzip&amp;amp;start.&amp;amp;end&lt;BR /&gt;317 datafile =&lt;BR /&gt;317! "\\dohfile02\phig\PHIGDATA\Data\perinatal_zips\perinzip_&amp;amp;start4._&amp;amp;end4.xlsx"&lt;BR /&gt;318 DBMS=XLSX REPLACE;&lt;BR /&gt;319 getnames = yes;&lt;BR /&gt;320 SHEET="PerinZIP_&amp;amp;start4._&amp;amp;end4";&lt;BR /&gt;321 options MSGLEVEL=i;&lt;BR /&gt;322 run;&lt;/P&gt;
&lt;P&gt;ERROR: Physical file does not exist,&lt;BR /&gt;\\dohfile02\phig\PHIGDATA\Data\perinatal_zips\perinzip_2018_2020xlsx.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 20:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-xlsx-file-using-macros-about-years/m-p/827221#M326751</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2022-08-04T20:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: import xlsx file using macros about years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-xlsx-file-using-macros-about-years/m-p/827222#M326752</link>
      <description>&lt;P&gt;&lt;SPAN&gt;\\dohfile02\phig\PHIGDATA\Data\perinatal_zips\perinzip_2018_&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;2020xlsx&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#333333"&gt;Macro processor ate the period. You need to have double periods for the file extension.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;datafile = "\\dohfile02\phig\PHIGDATA\Data\perinatal_zips\perinzip_&amp;amp;start4._&amp;amp;end4..xlsx"&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Aug 2022 20:39:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-xlsx-file-using-macros-about-years/m-p/827222#M326752</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-08-04T20:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: import xlsx file using macros about years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-xlsx-file-using-macros-about-years/m-p/827224#M326753</link>
      <description>Thanks Reeza. I tried that and still got an error. I must have a typo that I just can't find. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;153 proc import out = pzip&amp;amp;start.&amp;amp;end&lt;BR /&gt;154 datafile =&lt;BR /&gt;154! "\\dohfile02\phig\PHIGDATA\Data\perinatal_zips\perinzip_&amp;amp;start4._&amp;amp;end4..xlsx"&lt;BR /&gt;155 DBMS=XLSX REPLACE;&lt;BR /&gt;156 getnames = yes;&lt;BR /&gt;157 SHEET="PerinZIP_&amp;amp;start4._&amp;amp;end4";&lt;BR /&gt;158 options MSGLEVEL=i;&lt;BR /&gt;159 run;&lt;BR /&gt;&lt;BR /&gt;ERROR: Physical file does not exist,&lt;BR /&gt;\\dohfile02\phig\PHIGDATA\Data\perinatal_zips\perinzip_2018_2020.</description>
      <pubDate>Thu, 04 Aug 2022 20:45:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-xlsx-file-using-macros-about-years/m-p/827224#M326753</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2022-08-04T20:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: import xlsx file using macros about years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-xlsx-file-using-macros-about-years/m-p/827227#M326754</link>
      <description>&lt;P&gt;Okay, I apologize. It's a csv file, not an xlsx file. Really my bad. End of day and I wasn't careful. Sorry.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 20:52:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-xlsx-file-using-macros-about-years/m-p/827227#M326754</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2022-08-04T20:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: import xlsx file using macros about years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-xlsx-file-using-macros-about-years/m-p/827228#M326755</link>
      <description>&lt;P&gt;If you're on Unix file paths are case sensitive.&amp;nbsp;&lt;BR /&gt;If you're using Studio, go to Servers Folders and Files. Navigate to the path and right click the file. Copy the path exactly from properties and paste that into your program. If using EG or Foundation, the same thing can be done in the Explorer window.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If Windows go to the file, hold down CTRL+SHIFT+Right Click and Copy Path to get the exact path.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 20:54:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-xlsx-file-using-macros-about-years/m-p/827228#M326755</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-08-04T20:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: import xlsx file using macros about years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-xlsx-file-using-macros-about-years/m-p/827232#M326756</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31988"&gt;@geneshackman&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Okay, I apologize. It's a csv file, not an xlsx file. Really my bad. End of day and I wasn't careful. Sorry.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SAS was taking the easy way out on you. The DBMS = would have thrown an error if the file is actually CSV not XLSX.&lt;/P&gt;
&lt;P&gt;The SHEET= option would thrown an error as CSV files cannot have sheets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If all of these files that are name similarly mean that they are supposed to have the same content you might be much better off writing data step code to read them so all of the variables have the same properties. Proc Import on multiple similar files quite often means individual data sets end up with different properties such as variable length and sometimes type due to contents as the Procedure has to guess separately for each file what the properties are.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a minimum you want to set a large value for the GUESSINGROWS option if you use Proc Import with CSV so that more of the file is examined before properties for variables are set.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 21:03:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-xlsx-file-using-macros-about-years/m-p/827232#M326756</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-08-04T21:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: import xlsx file using macros about years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-xlsx-file-using-macros-about-years/m-p/827233#M326757</link>
      <description>&lt;P&gt;If CSV and multiple files you can avoid a macro and read all at once similar to the approach in this thread.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Retrieve-and-clean-all-files-in-a-directory-one-by-one/m-p/827202" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Retrieve-and-clean-all-files-in-a-directory-one-by-one/m-p/827202&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 21:14:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-xlsx-file-using-macros-about-years/m-p/827233#M326757</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-08-04T21:14:08Z</dc:date>
    </item>
  </channel>
</rss>

