<?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: reading a  csv file starting  from 4th row using proc import in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227698#M54206</link>
    <description>&lt;P&gt;If you know what the structure of the file will be, as in agreed upon by the providers and users, and the data columns remain in the same order and you know the characteristics such as length, format and data type then you use a data step to read the file. The infile statement would use the firstobs=4 or whatever to point to the data row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use Proc import to give you a leg up on writing the code by 1) putting an example file in a nice format such as row 1 = headers, 2) run proc import. The log will have the data step code generated to read the file. Copy that out and save as a separate program file. 3) modify the informats, formats and add label code and 4) change the Firstobs to match the actual data.&amp;nbsp;I would recommend modifying the code to use a filename statement and fileref in the data step for running against later data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With the data step code the only concerns become undocumented changes such as change of order of variables, changed number of header rows and changed lengths of variable contents.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2015 15:45:42 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2015-09-29T15:45:42Z</dc:date>
    <item>
      <title>reading a  csv file starting  from 4th row using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227657#M54199</link>
      <description>&lt;P&gt;i have a&amp;nbsp; csv file and&amp;nbsp; data starts&amp;nbsp; from&amp;nbsp; 4th road (3rd road is variable names).&lt;/P&gt;
&lt;P&gt;Is there a way i can&amp;nbsp; import it&amp;nbsp; using proc import?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 13:54:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227657#M54199</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2015-09-29T13:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: reading a  csv file starting  from 4th row using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227659#M54200</link>
      <description>Use this statement in the proc import&lt;BR /&gt;DATAROW=4; &lt;BR /&gt;</description>
      <pubDate>Tue, 29 Sep 2015 14:00:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227659#M54200</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2015-09-29T14:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: reading a  csv file starting  from 4th row using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227662#M54201</link>
      <description>&lt;P&gt;If you want to get the variable names from the file I believe that you'll need to delete or cut and paste the first two rows to another file. Currently proc import expects the variables to be on the first row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 14:06:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227662#M54201</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-09-29T14:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: reading a  csv file starting  from 4th row using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227666#M54202</link>
      <description>&lt;P&gt;Its not really a CSV file then is it. &amp;nbsp;CSV file has row 1 with column names, row 2 data starts and both are delimited by comma's. &amp;nbsp;You have a CSV "like" file. &amp;nbsp;Step one, infile the datafile, read whole thing and if _n_ &amp;gt; 2 then output to new file. &amp;nbsp;Step 2, read in the new file with just the headers and data.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 14:22:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227666#M54202</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-09-29T14:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: reading a  csv file starting  from 4th row using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227672#M54203</link>
      <description>&lt;P&gt;we&amp;nbsp; are trying to&amp;nbsp; put one&amp;nbsp; process&amp;nbsp; in production so&amp;nbsp; i cant&amp;nbsp; really play&amp;nbsp; with the&amp;nbsp; file (cutting,copying,pasting...) and&amp;nbsp; that file will come&amp;nbsp; in externaly as a&amp;nbsp; CSV one. So far they been sending a xls file where&amp;nbsp; data starts from 4th row but it was&amp;nbsp; easy to import it using the "startrow" and "namerow" within the proc import which does not work when it comes&amp;nbsp;&amp;nbsp; to CSV.&lt;/P&gt;
&lt;P&gt;So:&lt;/P&gt;
&lt;P&gt;1.&amp;nbsp; i should hope the csv file will always&amp;nbsp; have&amp;nbsp; the&amp;nbsp; headers&amp;nbsp; in the&amp;nbsp; first row and&amp;nbsp; data&amp;nbsp; from the second&amp;nbsp; onwards?&lt;/P&gt;
&lt;P&gt;2. infile the&amp;nbsp; csv file and&amp;nbsp;&amp;nbsp; read in&amp;nbsp; from _n_&amp;gt;2 ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you guys&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 14:38:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227672#M54203</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2015-09-29T14:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: reading a  csv file starting  from 4th row using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227674#M54204</link>
      <description>&lt;P&gt;proc import datafile="path/Have.csv"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dbms=csv&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out=Want&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; replace;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; datarow=2;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As &lt;SPAN class="UserName lia-user-name lia-user-rank-Trusted-Advisor"&gt; &lt;A id="link_17" class="lia-link-navigation lia-page-link lia-user-name-link" style="color: #007dc3;" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884" target="_self"&gt;&lt;SPAN class="login-bold"&gt;ballardw&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt; says, you could not get the names with proc import if doesn't start in the first row&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 14:47:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227674#M54204</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2015-09-29T14:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: reading a  csv file starting  from 4th row using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227675#M54205</link>
      <description>&lt;P&gt;PROC IMPORT will help you with a well-formed CSV file -- glean variable names from the first row, and "guess" the variable types based on the remaining data rows. &amp;nbsp;But as others point out, this depends on having data begin in the second row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there are blank rows, or rows that contain information that is&amp;nbsp;&lt;STRONG&gt;not&lt;/STRONG&gt; data, then PROC IMPORT might not behave as well. &amp;nbsp;In this case it might be better to use INFILE with a CSV file. &amp;nbsp;But you'll need to define the variable attributes, informats, and exert more control over how the file is read in. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Behind the scenes, PROC IMPORT generates DATA step code to do its work, so you might consider just short-circuiting that and write your own DATA step for full control. &amp;nbsp;More work, but brings you more flexibility over reading a file whose format you don't control.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 14:51:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227675#M54205</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2015-09-29T14:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: reading a  csv file starting  from 4th row using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227698#M54206</link>
      <description>&lt;P&gt;If you know what the structure of the file will be, as in agreed upon by the providers and users, and the data columns remain in the same order and you know the characteristics such as length, format and data type then you use a data step to read the file. The infile statement would use the firstobs=4 or whatever to point to the data row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use Proc import to give you a leg up on writing the code by 1) putting an example file in a nice format such as row 1 = headers, 2) run proc import. The log will have the data step code generated to read the file. Copy that out and save as a separate program file. 3) modify the informats, formats and add label code and 4) change the Firstobs to match the actual data.&amp;nbsp;I would recommend modifying the code to use a filename statement and fileref in the data step for running against later data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With the data step code the only concerns become undocumented changes such as change of order of variables, changed number of header rows and changed lengths of variable contents.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 15:45:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227698#M54206</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-09-29T15:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: reading a  csv file starting  from 4th row using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227702#M54207</link>
      <description>&lt;P&gt;Well, you have some technical advice above. &amp;nbsp;I would just like to add that it is all in the documentation. &amp;nbsp;Ensure you have a document which describes the CSV data. &amp;nbsp;This should be signed by both parties and ahered to. &amp;nbsp;The programming is a very simple matter then, merely coding the information in the agreement, but without an agreement you could end up changing things each time. &amp;nbsp;Simple programming advice:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Document&lt;/P&gt;
&lt;P&gt;Agree&lt;/P&gt;
&lt;P&gt;then&lt;/P&gt;
&lt;P&gt;Code.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 15:53:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/227702#M54207</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-09-29T15:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: reading a  csv file starting  from 4th row using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/230320#M54477</link>
      <description>&lt;P&gt;yea CSV files indeed come as you&amp;nbsp; said RW9 so i panicked&amp;nbsp; for no reasons&amp;nbsp; but&amp;nbsp; thank you guys for the&amp;nbsp; hints&lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2015 16:06:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/230320#M54477</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2015-10-16T16:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: reading a  csv file starting  from 4th row using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/230414#M54491</link>
      <description>&lt;P&gt;Hi.&amp;nbsp; If you have an XLS file with the first two rows blank, column names in row 3, data starting in row 4 ... try this with the attached XLS file ...&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;libname x 'z:\test.xls';&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;data new;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;set x.'sheet1$'n ;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;libname x clear;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data set NEW ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;Obs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; z&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date&amp;nbsp;&amp;nbsp;&amp;nbsp; name&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&amp;nbsp;&amp;nbsp;&amp;nbsp; 15OCT2015&amp;nbsp;&amp;nbsp;&amp;nbsp; HEY&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 99&amp;nbsp;&amp;nbsp;&amp;nbsp; 99&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp; 01JAN1960&amp;nbsp;&amp;nbsp;&amp;nbsp; IT&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp; 11NOV2011&amp;nbsp;&amp;nbsp;&amp;nbsp; WORKS&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Oct 2015 15:59:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-a-csv-file-starting-from-4th-row-using-proc-import/m-p/230414#M54491</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2015-10-17T15:59:49Z</dc:date>
    </item>
  </channel>
</rss>

