<?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: Need help with importing in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/612845#M178911</link>
    <description>&lt;P&gt;You can use Powershell and the&amp;nbsp;&lt;SPAN&gt;Microsoft.ACE.OLEDB.12.0 provider to query Excel like a database (which it most certainly is NOT!)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can then call the Powershell script from SAS using filename pipe, streaming the results as CSV.&amp;nbsp; The Excel workbook must be closed at the time or you'll get file locking issues.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can use PROC IMPORT against that CSV to generate a data step, then cut-and-paste the results from the SAS log and edit as required.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here's hoping the structure of your Excel file does not change over time.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;See here for the Powershell script:&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/scottbass/Powershell/blob/master/Scripts/Query-Excel.ps1" target="_blank"&gt;https://github.com/scottbass/Powershell/blob/master/Scripts/Query-Excel.ps1&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope this helps a bit...&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Dec 2019 21:06:15 GMT</pubDate>
    <dc:creator>ScottBass</dc:creator>
    <dc:date>2019-12-18T21:06:15Z</dc:date>
    <item>
      <title>Need help with importing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/612239#M178595</link>
      <description>&lt;P&gt;Hi Gurus,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to read in a xlsx file, where one column has values like these:&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="Capture.PNG" style="width: 213px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34846iF39F6BF1DCB34020/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After proc import, some values become the values shown below. Can someone tell me how to remain the original value? Thanks a bunch!!&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="Capture 2.PNG" style="width: 234px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34847i9FF9A483900A0B1B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture 2.PNG" alt="Capture 2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 22:07:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/612239#M178595</guid>
      <dc:creator>YimingWeng</dc:creator>
      <dc:date>2019-12-16T22:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with importing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/612250#M178603</link>
      <description>&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=acpcref&amp;amp;docsetTarget=p0jf3o1i67m044n1j0kz51ifhpvs.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=acpcref&amp;amp;docsetTarget=p0jf3o1i67m044n1j0kz51ifhpvs.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=acpcref&amp;amp;docsetTarget=n0msy4hy1so0ren1acm90iijxn8j.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=acpcref&amp;amp;docsetTarget=n0msy4hy1so0ren1acm90iijxn8j.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See MIXED option, then use a subsequent data step to convert "real" numeric data to numbers.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 22:56:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/612250#M178603</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-12-16T22:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with importing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/612253#M178606</link>
      <description>Is your original file XLSX? Or XML? I would consider converting it to CSV and importing that, though if you have quotes anywhere in there it may end up more messy. &lt;BR /&gt;</description>
      <pubDate>Mon, 16 Dec 2019 23:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/612253#M178606</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-12-16T23:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with importing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/612270#M178616</link>
      <description>&lt;P&gt;Yet another lesson about the dangers of using spreadsheets to enter data and transport.&lt;/P&gt;
&lt;P&gt;You have a very big clue as to what is going on in the picture. Note that some of the cells have values that are right justified like 99,100. If you check the cell format in Excel you will likely find that it is&amp;nbsp;Number with the thousands separator set to comma.&lt;/P&gt;
&lt;P&gt;The other cells did not do that because there were not 3 digits after the comma (so not valid numbers) or appeared within the brackets. The one with 161, 162, 163 also did not convert to numeric because of the space after the comma.&lt;/P&gt;
&lt;P&gt;The cell with the value of 68 is likely of "General" format&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the data was actually entered directly into the spreadsheet then that is a part of the issue: allowing Excel to guess what you meant.&lt;/P&gt;
&lt;P&gt;If the data was created somewhere and then opened and Saved by Excel that could modify values depending on the source file type.&lt;/P&gt;
&lt;P&gt;SAS will only allow a variable to have a single type, numeric or character. Depending on the actual contents of the cell then the import engine will make "best guess" as to contents.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would also check to see that you have "complete" values for records further down in the data file. You didn't say exactly how you are attempting to read this file but if using Proc Import then properties could be set with examining only 20 rows of data and if you have a value like [1234,1235,1236,1237] it may get truncated because none of the first rows had a value that long.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this file started out as exported from some program and then was edited in Excel you may have to go back to that original file and try importing or reading a version that was not edited by Excel.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 23:56:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/612270#M178616</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-12-16T23:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with importing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/612419#M178696</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply, this was one thing that i tried but i got this error message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anything i did wrong?&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="2.PNG" style="width: 585px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34874i362B5C60F74DC306/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.PNG" alt="2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Dec 2019 15:01:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/612419#M178696</guid>
      <dc:creator>YimingWeng</dc:creator>
      <dc:date>2019-12-17T15:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with importing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/612420#M178697</link>
      <description>&lt;P&gt;I was wondering if you will see my post and reply:)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Original file is google sheet actually, i downloaded as xlsx.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I converted as csv and it works well, thanks so much Reeza!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Dec 2019 15:03:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/612420#M178697</guid>
      <dc:creator>YimingWeng</dc:creator>
      <dc:date>2019-12-17T15:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with importing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/612422#M178699</link>
      <description>&lt;P&gt;Thanks so much for the in-depth explanation for excel formatting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data is from a google app, IT created a google sheet for me as export, I then download as xlsx format. In terms of input restriction, it is almost like excel because front users can enter whatever in that field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried Proc Import, not working, so I followed Reeza's tip to convert into csv and do data infile, now it's working, i just need to define all columns which is a little bit of work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ideally I should be connecting to the back end database directly to gain efficiency and accuracy in this matter, but I was told that SAS is not able to connect to GCP yet? So every week I am doing google sheet to xlsx to SAS data set conversion routine, lucky me:)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again thanks for your help, at least now i have a temporary solution!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Dec 2019 15:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/612422#M178699</guid>
      <dc:creator>YimingWeng</dc:creator>
      <dc:date>2019-12-17T15:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with importing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/612845#M178911</link>
      <description>&lt;P&gt;You can use Powershell and the&amp;nbsp;&lt;SPAN&gt;Microsoft.ACE.OLEDB.12.0 provider to query Excel like a database (which it most certainly is NOT!)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can then call the Powershell script from SAS using filename pipe, streaming the results as CSV.&amp;nbsp; The Excel workbook must be closed at the time or you'll get file locking issues.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can use PROC IMPORT against that CSV to generate a data step, then cut-and-paste the results from the SAS log and edit as required.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here's hoping the structure of your Excel file does not change over time.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;See here for the Powershell script:&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/scottbass/Powershell/blob/master/Scripts/Query-Excel.ps1" target="_blank"&gt;https://github.com/scottbass/Powershell/blob/master/Scripts/Query-Excel.ps1&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope this helps a bit...&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 21:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/612845#M178911</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-12-18T21:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with importing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/613270#M179091</link>
      <description>&lt;P&gt;Thanks so much for the detailed solution, I will follow your instruction and learn:)&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2019 16:10:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing/m-p/613270#M179091</guid>
      <dc:creator>YimingWeng</dc:creator>
      <dc:date>2019-12-20T16:10:31Z</dc:date>
    </item>
  </channel>
</rss>

