<?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: file formats in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/447080#M112245</link>
    <description>&lt;P&gt;Unfortunately converting to &lt;STRIKE&gt;XLSX &lt;/STRIKE&gt;CSV is the best solution. You could add a check to ensure your data meets the expected format but IMO that’s more work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are macros row and scripts that will convert all your XLSX and XLSX to CSV in batch.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ultimately however, it’s your choice which approach to take. Do consider what happens if you go with the Excel approach and and it decides to add two extra columns next time or a bunch of empty rows. Is your process robust enough to handle that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: I typed XLSX when I meant CSV.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The script is here and the code is 6 to create a CSV (51 for XLSX in the code).&lt;/P&gt;
&lt;P&gt;&lt;A href="https://msdn.microsoft.com/en-us/vba/excel-vba/articles/xlfileformat-enumeration-excel" target="_blank"&gt;https://msdn.microsoft.com/en-us/vba/excel-vba/articles/xlfileformat-enumeration-excel&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; options noxwait noxsync; 
 
%macro convert_files(default=,ext=);
 
data _null_;
file "'&amp;amp;default\temp.vbs'";
put "set xlapp = CreateObject(""Excel.Application"")";
put "set fso = CreateObject(""scripting.filesystemobject"")";
put "set myfolder = fso.GetFolder(""&amp;amp;default"")";
put "set myfiles = myfolder.Files";
put "xlapp.DisplayAlerts = False";
put " ";
put "for each f in myfiles";
put "  ExtName = fso.GetExtensionName(f)";
put "  Filename= fso.GetBaseName(f)";
put "    if ExtName=""&amp;amp;ext"" then";
put "           set mybook = xlapp.Workbooks.Open(f.Path)"; 
put "           xlapp.Visible = false";
put "           mybook.SaveAs ""&amp;amp;default.\"" &amp;amp; Filename &amp;amp; "".csv"", 6";
put "    End If";
put "  Next";
put "  mybook.Close";
put "  xlapp.DisplayAlerts = True";
/* Removes original files */
/*put " FSO.DeleteFile(""&amp;amp;default\*.&amp;amp;ext""), DeleteReadOnly";*/
put " xlapp.Quit";
put " Set xlapp = Nothing";
put " strScript = Wscript.ScriptFullName";
put " FSO.DeleteFile(strScript)"; 
run; 
 
x "cscript ""&amp;amp;default\temp.vbs""";
 
%mend;
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Source:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/43/496.html" target="_blank"&gt;http://support.sas.com/kb/43/496.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Mar 2018 15:24:41 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-03-20T15:24:41Z</dc:date>
    <item>
      <title>file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/446764#M112148</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have been struggling with the below file issue. My project is ready to get deployed next week and now we started facing the below issues wih the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We receive .XLS and .XLSX files from various countries, which looks like attached. Once imported, the default column names (A B C D.... or F1 F2 F3....) will be assigned and then we coded the rest accordingly. till now everything was going good, lately when we import the file, the code is createing an extra column in the first place of the file which is moving the rest of the columns to right thus F1 becomes F2 so on.. and because of this the code is picking incorrect data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I dont understand how this can happen. Please help me understand and kindly advise on solution for this..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 13:36:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/446764#M112148</guid>
      <dc:creator>don21</dc:creator>
      <dc:date>2018-03-19T13:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/446775#M112152</link>
      <description>&lt;P&gt;I won't look at the attached .xlsx file, because downloading and opening .xlsx files are security risk. However, the question I have for you is: did you actually look at the .xlsx file that is the problem? What is in column A? Is it the expected data, or is it the unexpected extra column? Can you show us a screen capture of what the first few rows and columns of the .xlsx file which is causing the problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Long-term, this is a problem using .xlsx files to transmit the data, that the format of the file can change and then your code won't work.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 14:06:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/446775#M112152</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-03-19T14:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/446778#M112154</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/51418"&gt;@don21&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have been struggling with the below file issue. My project is ready to get deployed next week and now we started facing the below issues wih the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We receive .XLS and .XLSX files from various countries, which looks like attached. Once imported, the default column names (A B C D.... or F1 F2 F3....) will be assigned and then we coded the rest accordingly. till now everything was going good, lately when we import the file, the code is createing an extra column in the first place of the file which is moving the rest of the columns to right thus F1 becomes F2 so on.. and because of this the code is picking incorrect data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I dont understand how this can happen. Please help me understand and kindly advise on solution for this..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So show the code that is reading the .xls and/or .xlsx files. That statement alone raises concerns because the file structures are different and have different limitations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My guess without an example is that you are 1) using proc import and 2) one or more of the data providers changed the file layout without telling you.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 14:09:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/446778#M112154</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-19T14:09:23Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/446786#M112161</link>
      <description>&lt;P&gt;First of all, stop using Excel files and only accept text-based files, either fixed-width or csv.&lt;/P&gt;
&lt;P&gt;Second, stop using Excel files and only accept text-based files, either fixed-width or csv.&lt;/P&gt;
&lt;P&gt;Third, stop using Excel files and only accept text-based files, either fixed-width or csv.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As long as you accept garbage, the stink won't go away.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 14:17:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/446786#M112161</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-19T14:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/446803#M112170</link>
      <description>&lt;P&gt;This means the Excel files do not have the same structure. Since Excel is not a database it does’t enforce types.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This willl definitely be problematic in a production type process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should convert the file to a CSV and read that in instead. You can control the types/formats as desired and ensure you always have the same data inputted or at least know if you don’t.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 14:42:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/446803#M112170</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-19T14:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/447039#M112231</link>
      <description>Hi KurtBremser,&lt;BR /&gt;&lt;BR /&gt;I agree to what you said, unfortunately I don't have the authority to reject garbage. No matter what, I have to automated the crap that I get. With a lot of patience, I did but now this? Please advise.&lt;BR /&gt;&lt;BR /&gt;Regards..</description>
      <pubDate>Tue, 20 Mar 2018 10:01:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/447039#M112231</guid>
      <dc:creator>don21</dc:creator>
      <dc:date>2018-03-20T10:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/447045#M112232</link>
      <description>Hi Reeza,&lt;BR /&gt;&lt;BR /&gt;I receve data for 14 countries. Each country sends atleast 20 excel files (both .xls and .xlsx), If I have to change the codes to CSV conversions at this point, it wont be feasible and lot of things can go wrong while doing this.&lt;BR /&gt;&lt;BR /&gt;Also, the structure of the input files loosk exactly the same including the blank columns. The code itself is creating a blank column sometimes.&lt;BR /&gt;&lt;BR /&gt;I understand that working with excel files is complete wate of time but at this point where my project is ready to go live, I need some solution to fix this..&lt;BR /&gt;&lt;BR /&gt;Please help!</description>
      <pubDate>Tue, 20 Mar 2018 10:24:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/447045#M112232</guid>
      <dc:creator>don21</dc:creator>
      <dc:date>2018-03-20T10:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/447047#M112233</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/51418"&gt;@don21&lt;/a&gt; wrote:&lt;BR /&gt;Hi KurtBremser,&lt;BR /&gt;&lt;BR /&gt;I agree to what you said, unfortunately I don't have the authority to reject garbage. No matter what, I have to automated the crap that I get. With a lot of patience, I did but now this? Please advise.&lt;BR /&gt;&lt;BR /&gt;Regards..&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You have a fundamentally broken process. That needs to be fixed first.&lt;/P&gt;
&lt;P&gt;I couldn't maintain 1000+ SAS jobs on my own (which I do) without proper processes.&lt;/P&gt;
&lt;P&gt;Make it clear to the people responsible that keeping that mess up will cost MONEY in terms of your unnecessarily wasted time, as you will have to go on fixing and fixing it time and again. While you could do really useful stuff.&lt;/P&gt;
&lt;P&gt;Invest the time NOW to set up a proper process (sensible file format, documented structure, agreement between provider and receiver). It will be worth it, a hundred times over. Not exagerrating here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I really mean it. You can quote me on this. And &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; probably too.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 10:55:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/447047#M112233</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-20T10:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/447066#M112240</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/51418"&gt;@don21&lt;/a&gt; wrote:&lt;BR /&gt;&lt;BR /&gt;I understand that working with excel files is complete waste of time but at this point where my project is ready to go live, I need some solution to fix this..&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you code does not contain steps to detect and fix excel-files not having the expected structure, your project is not ready to go live. You have to check every variable and ensure that it has the expected type and length.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you post the code used to read the excel files?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 12:23:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/447066#M112240</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-03-20T12:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/447080#M112245</link>
      <description>&lt;P&gt;Unfortunately converting to &lt;STRIKE&gt;XLSX &lt;/STRIKE&gt;CSV is the best solution. You could add a check to ensure your data meets the expected format but IMO that’s more work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are macros row and scripts that will convert all your XLSX and XLSX to CSV in batch.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ultimately however, it’s your choice which approach to take. Do consider what happens if you go with the Excel approach and and it decides to add two extra columns next time or a bunch of empty rows. Is your process robust enough to handle that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: I typed XLSX when I meant CSV.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The script is here and the code is 6 to create a CSV (51 for XLSX in the code).&lt;/P&gt;
&lt;P&gt;&lt;A href="https://msdn.microsoft.com/en-us/vba/excel-vba/articles/xlfileformat-enumeration-excel" target="_blank"&gt;https://msdn.microsoft.com/en-us/vba/excel-vba/articles/xlfileformat-enumeration-excel&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; options noxwait noxsync; 
 
%macro convert_files(default=,ext=);
 
data _null_;
file "'&amp;amp;default\temp.vbs'";
put "set xlapp = CreateObject(""Excel.Application"")";
put "set fso = CreateObject(""scripting.filesystemobject"")";
put "set myfolder = fso.GetFolder(""&amp;amp;default"")";
put "set myfiles = myfolder.Files";
put "xlapp.DisplayAlerts = False";
put " ";
put "for each f in myfiles";
put "  ExtName = fso.GetExtensionName(f)";
put "  Filename= fso.GetBaseName(f)";
put "    if ExtName=""&amp;amp;ext"" then";
put "           set mybook = xlapp.Workbooks.Open(f.Path)"; 
put "           xlapp.Visible = false";
put "           mybook.SaveAs ""&amp;amp;default.\"" &amp;amp; Filename &amp;amp; "".csv"", 6";
put "    End If";
put "  Next";
put "  mybook.Close";
put "  xlapp.DisplayAlerts = True";
/* Removes original files */
/*put " FSO.DeleteFile(""&amp;amp;default\*.&amp;amp;ext""), DeleteReadOnly";*/
put " xlapp.Quit";
put " Set xlapp = Nothing";
put " strScript = Wscript.ScriptFullName";
put " FSO.DeleteFile(strScript)"; 
run; 
 
x "cscript ""&amp;amp;default\temp.vbs""";
 
%mend;
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Source:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/43/496.html" target="_blank"&gt;http://support.sas.com/kb/43/496.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 15:24:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/447080#M112245</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-20T15:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/447244#M112296</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/51418"&gt;@don21&lt;/a&gt; wrote:&lt;BR /&gt;Hi Reeza,&lt;BR /&gt;&lt;BR /&gt;I receve data for 14 countries. Each country sends atleast 20 excel files (both .xls and .xlsx), If I have to change the codes to CSV conversions at this point, it wont be feasible and lot of things can go wrong while doing this.&lt;BR /&gt;&lt;BR /&gt;Also, the structure of the input files loosk exactly the same including the blank columns. &lt;STRONG&gt;&lt;FONT color="#ff0000" size="5"&gt;The code itself is creating a blank column sometimes.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;I understand that working with excel files is complete wate of time but at this point where my project is ready to go live, I need some solution to fix this..&lt;BR /&gt;&lt;BR /&gt;Please help!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It is real hard to fix code without seeing any code. No code, no fix to code. Simple solution set.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 19:28:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/447244#M112296</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-20T19:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/448052#M112657</link>
      <description>&lt;P&gt;Hi Ballardw,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PFB sample example code that we used:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;option obs=max;&lt;BR /&gt;proc import datafile= "//&amp;lt;&amp;lt;&amp;lt;Path&amp;gt;&amp;gt;/ABCD.xlsx"&lt;BR /&gt;out=ABCD&lt;BR /&gt;dbms=xlsx replace;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;DATA ABCD1;&lt;BR /&gt;SET ABCD ( KEEP = A B H I J P Q R S U); /** after renaming the A B... variables, they will be dropped at the end*/&lt;BR /&gt;&amp;lt;&amp;lt;&amp;gt;&amp;gt;&lt;BR /&gt;&amp;lt;&amp;lt;&amp;gt;&amp;gt;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 04:47:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/448052#M112657</guid>
      <dc:creator>don21</dc:creator>
      <dc:date>2018-03-23T04:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/448054#M112658</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13584"&gt;@Andre&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi, We have checked every possibility that could go wrong, I have taken over this project recently&amp;nbsp; and the test runs went well t=until now. Now a days the input file formats have been creating issues although they look as as the previous ones. we could not get back tot he providers as we could not spot the difference between the files.. SAS is creating blank columns in between is my best guess in this situation or there must be some internal format issue with the input file which we couldnt spot.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 04:52:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/448054#M112658</guid>
      <dc:creator>don21</dc:creator>
      <dc:date>2018-03-23T04:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/448055#M112659</link>
      <description>&lt;P&gt;option obs=max;&lt;BR /&gt;proc import datafile= "//&amp;lt;&amp;lt;path&amp;gt;&amp;gt;/ABCD.xlsx"&lt;BR /&gt;out=ABCD&lt;BR /&gt;dbms=xlsx replace;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;DATA ABCD1;&lt;BR /&gt;FORMAT Current_Excess BEST.;&lt;BR /&gt;SET ABCD ( KEEP = A B H I J P Q R S U);&lt;BR /&gt;RETAIN RM_NAME Entity_Name RM_CODE Limit_Product_Type Account_ReferenceNo System_ID;&lt;BR /&gt;IF INDEX (A, "Name :")&amp;gt;0 THEN RNAME = B;&lt;BR /&gt;IF INDEX (A, "Customer :")&amp;gt;0 THEN Entity = B;&lt;BR /&gt;IF INDEX (A, "Code :")&amp;gt;0 THEN CODE = B;&lt;BR /&gt;IF INDEX (A,"Product :") THEN Limit_Product = B;&lt;BR /&gt;IF INDEX (A,"Id :") THEN ReferenceNo = B;&lt;BR /&gt;IF INDEX (A,"Id :") THEN ID = B;&lt;BR /&gt;CURRENCY =P;&lt;BR /&gt;Current_Excess = Q;&lt;BR /&gt;/*Current_Excess = INPUT (Current_Exces,BEST.);*/&lt;BR /&gt;NO_OF_DAYS_InExcess =U ;&lt;BR /&gt;Excess_Sin = S;&lt;BR /&gt;CODE = I;&lt;BR /&gt;NAME = J;&lt;BR /&gt;EXCESS_SINCE = INPUT (EXCESS_SIN, COMMA8.);&lt;BR /&gt;EXCESS_SINCE = EXCESS_SINCE - 21916;&lt;BR /&gt;FORMAT EXCESS_SINCE DATE11.;&lt;BR /&gt;LENGTH FILENAME $50. REPORT $30.;&lt;BR /&gt;FILENAME = "ABCD";&lt;BR /&gt;REPORT = "ABCD";&lt;BR /&gt;IF CURRENCY IN (" ", "Fin Ccy") THEN DELETE;&lt;BR /&gt;DROP A B H I J S P Q R U EXCESS_SIN;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SORT DATA = ABCD1 OUT = ABCD_FINAL noduprecs;&lt;BR /&gt;BY NAME;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sample code for a file....&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 05:00:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/448055#M112659</guid>
      <dc:creator>don21</dc:creator>
      <dc:date>2018-03-23T05:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/448323#M112766</link>
      <description>&lt;P&gt;Usually, in my experience, this happens if you have formulas or had information and deleted but had a format attached. Excel is still keeping that information somewhere so SAS thinks it has info.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you data is always in specific columns though, you could specify the range start and column end and see if that alone fixes it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 20:44:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/448323#M112766</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-23T20:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/448326#M112767</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/51418"&gt;@don21&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi Ballardw,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PFB sample example code that we used:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;option obs=max;&lt;BR /&gt;proc import datafile= "//&amp;lt;&amp;lt;&amp;lt;Path&amp;gt;&amp;gt;/ABCD.xlsx"&lt;BR /&gt;out=ABCD&lt;BR /&gt;dbms=xlsx replace;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;DATA ABCD1;&lt;BR /&gt;SET ABCD ( KEEP = A B H I J P Q R S U); /** after renaming the A B... variables, they will be dropped at the end*/&lt;BR /&gt;&amp;lt;&amp;lt;&amp;gt;&amp;gt;&lt;BR /&gt;&amp;lt;&amp;lt;&amp;gt;&amp;gt;&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your PROC IMPORT code is telling SAS to read the variable names from the first row in the file. So if someone changes the first row then the variable names will change.&amp;nbsp; You could tell SAS not to read the variable names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your PROC IMPORT code is not telling SAS which sheet to read from the workbook.&amp;nbsp; What happens if they send one workbookwith three sheets?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 20:51:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/448326#M112767</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-23T20:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/448390#M112779</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/51418"&gt;@don21&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Like others already wrote Excel is unsuitable for data exchange. But I also understand that this might be out of your control. You will just need to be very clear with your client/manager that there is quite a big likelihood for ongoing production issues with such source data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Comparing the sample Excel with your code demonstrates one of the issues: In your code you're reading &lt;EM&gt;NO_OF_DAYS_InExcess&lt;/EM&gt;&amp;nbsp;from column U while in your sample Excel it's on column V.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When dealing with Excels and especially when the sheet actually contains reports and is not just a data sheet, you need to code&amp;nbsp;with much more checks and balances than what your code sample demonstrates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't trust on which column a report starts. Analyse the "raw" data first to determine the structure (i.e. search on which column you find a token like "Client ID" - just something which is unique and gives you the starting point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Client ID &lt;/EM&gt;should also give you the left top corner of a table. So next step for me would be to analyse the table headings on this row and determine if they follow an expected structure. Only if that's validated I'd go and map the data to my output columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically: You need much more analysis of the source structure and you need much more validation than what the code you've posted demonstrates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've been once in a similar situation. My approach was to first convert the Excels to .CSV as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;proposes, then implement all the checks and balances and create a .csv structure as I'd really would have needed it as a data source. After this step I could go for a clean ETL process.&lt;/P&gt;
&lt;P&gt;This allowed me to separate "the mess" from the rest of the process and as I've been optimistic also communicate back to the client what data exchange format&amp;nbsp;they should aim for in a future release (and then hoping the only change required to my code could be to remove the "messy" conversion step). ....I believe this never happened but it certainly helped operationally to&amp;nbsp;separate issues with unreliable data sources from the rest of the process&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 10:39:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/448390#M112779</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-03-27T10:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/448905#M112919</link>
      <description>&lt;P&gt;Sure, Thank you Patric.. I requested my clients if the could give the inputs in any other formats.. They suggested &lt;STRONG&gt;.RPT&lt;/STRONG&gt;. Well, I have never used that before, tried to google for syntax but no use. Any views on how to do that? because, if this is good, atleast I can buy sometime and do the modifications in my project.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many Thanks..&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 08:59:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/448905#M112919</guid>
      <dc:creator>don21</dc:creator>
      <dc:date>2018-03-27T08:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/448913#M112925</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;An RPT file is a report or output file created by Crystal Reports&lt;/SPAN&gt;" (&lt;A href="https://fileinfo.com/extension/rpt" target="_blank"&gt;https://fileinfo.com/extension/rpt&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This file-format is even worse than Excel.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 09:18:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/448913#M112925</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-03-27T09:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: file formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/448929#M112934</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/51418"&gt;@don21&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;In the end of the day your client is the king and if you can help them to shape their data into a form where they can get value out of it then this is your job. This is clearly a business driven project with people in it who don't have too much understanding of data organization. But that's likely why they've engaged with you. You're the expert and you can do it for them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The one thing you&amp;nbsp;probably should do to&amp;nbsp;protect yourself: Write down some sort of interface specification (not IT style but made up business style) where you define the few elements which are essential for your code to work (like sheet name, the name of the "tokens" you use in your code to find the starting point of data, and the name of the column headings) - and have your customer confirm that they can deliver on this. This won't only you, it will also help your customer to understand what they have to pay attention to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The comparable (forecasting) project I've been in: It was ugly from an ETL perspective. Quite a few of the Excel extracts where actually SAP reports and accessing SAP directly would have been the clean way to go. But that was just not possible in the context (SAP owned by HQ, project run by a country agency). ...But then: Once I was able to create a "clean data warehouse" my customer was able to add that much value to the available data (much better forecasts) that the approach went global (big multinational) and then of course things got built much cleaner. I hadn't really been involved in this stage anymore but still: What started as a big ugly mess ended as something which I consider as one of the successes in my professional career.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 11:14:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/file-formats/m-p/448929#M112934</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-03-27T11:14:53Z</dc:date>
    </item>
  </channel>
</rss>

