<?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: Using proc import to read .csv with datarow= option in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-import-to-read-csv-with-datarow-option/m-p/149566#M39464</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I added the dbms=csv although usually its not necessary because csv is part of the file extension.&amp;nbsp; Unfortunately SAS still assigned VAR1, VAR2, VAR3.......&amp;nbsp; So I just deleted the rows from the raw data file that I didn't want SAS to read.&amp;nbsp; I try not make a habit of doing that since I would rather write code around how the raw data is formatted than rely on being able modify it.&amp;nbsp; Thanks for your input.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Dec 2014 01:05:55 GMT</pubDate>
    <dc:creator>ahvargas</dc:creator>
    <dc:date>2014-12-16T01:05:55Z</dc:date>
    <item>
      <title>Using proc import to read .csv with datarow= option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-import-to-read-csv-with-datarow-option/m-p/149561#M39459</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have several csv files of NBA stats with about 30 variables each and I am attempting to use proc import to create the data set, with SAS University Edition.&amp;nbsp; SAS successfully reads the data, however, doesn't get names for the variables and instead assigns VAR1 VAR2 VAR3....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The actual data (mostly numeric, and a few character) sometimes begins on the 2nd row, other times it will start in row 3 or 4.&amp;nbsp; &lt;SPAN style="text-decoration: underline;"&gt;The category names (which would become the variable names in the data set) are always in the previous row.&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Here's my code and three csv files for reference.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I've successfully imported nearly identical files (sports statistics) with proc import so I'm puzzled why it isn't working this time.&amp;nbsp; (fyi - csv file name is in the respective proc import code)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc import datafile='&lt;EM&gt;leagues_NBA_2014_team.csv'&lt;/EM&gt; out=&lt;EM&gt;team&lt;/EM&gt; replace;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datarow=2; getnames=yes;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc import datafile='leagues_NBA_2014_shooting.csv' out=shooting replace;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datarow=4; getnames=yes;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc import datafile='leagues_NBA_2014_misc.csv' out=misc replace;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datarow=3; getnames=yes;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 Dec 2014 23:34:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-import-to-read-csv-with-datarow-option/m-p/149561#M39459</guid>
      <dc:creator>ahvargas</dc:creator>
      <dc:date>2014-12-13T23:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc import to read .csv with datarow= option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-import-to-read-csv-with-datarow-option/m-p/149562#M39460</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try the namerow option to specify what rows the variable names are in&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;proc import datafile='leagues_NBA_2014_misc.csv' out=misc replace;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp; datarow=3; namerow=2; getnames=yes;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Dec 2014 00:44:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-import-to-read-csv-with-datarow-option/m-p/149562#M39460</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-12-14T00:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc import to read .csv with datarow= option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-import-to-read-csv-with-datarow-option/m-p/149563#M39461</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I get the following error:&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;398 proc import datafile='/folders/myfolders/sports/nba/2013-14/leagues_NBA_2014_misc.csv' out=nba.misc replace;&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt; NOTE: The previous statement has been deleted.&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt; 399 datarow=3; namerow=1; getnames=yes;&lt;/P&gt;&lt;P class="sasError" style="color: #ff0000;"&gt;&amp;nbsp; _______&lt;/P&gt;&lt;P class="sasError" style="color: #ff0000;"&gt;&amp;nbsp; 180&lt;/P&gt;&lt;P class="sasError" id="sasLogError3_1418579774702" style="color: #ff0000;"&gt; ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Dec 2014 18:30:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-import-to-read-csv-with-datarow-option/m-p/149563#M39461</guid>
      <dc:creator>ahvargas</dc:creator>
      <dc:date>2014-12-14T18:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc import to read .csv with datarow= option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-import-to-read-csv-with-datarow-option/m-p/149564#M39462</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt; I'm out of ideas, hopefully someone else will have some.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Dec 2014 22:41:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-import-to-read-csv-with-datarow-option/m-p/149564#M39462</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-12-15T22:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc import to read .csv with datarow= option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-import-to-read-csv-with-datarow-option/m-p/149565#M39463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;dbms=csv&lt;/P&gt;&lt;P&gt;on the proc statement perhaps?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Dec 2014 23:12:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-import-to-read-csv-with-datarow-option/m-p/149565#M39463</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-12-15T23:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc import to read .csv with datarow= option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-import-to-read-csv-with-datarow-option/m-p/149566#M39464</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I added the dbms=csv although usually its not necessary because csv is part of the file extension.&amp;nbsp; Unfortunately SAS still assigned VAR1, VAR2, VAR3.......&amp;nbsp; So I just deleted the rows from the raw data file that I didn't want SAS to read.&amp;nbsp; I try not make a habit of doing that since I would rather write code around how the raw data is formatted than rely on being able modify it.&amp;nbsp; Thanks for your input.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2014 01:05:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-import-to-read-csv-with-datarow-option/m-p/149566#M39464</guid>
      <dc:creator>ahvargas</dc:creator>
      <dc:date>2014-12-16T01:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc import to read .csv with datarow= option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-import-to-read-csv-with-datarow-option/m-p/149567#M39465</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="842741" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/" modifiedtitle="true" title="ahvargas:"&gt;&lt;/A&gt; I don't think your problem is where the data starts but, rather, how many rows are needed to build the variable names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following will read your three example files:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro importc(type);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if %upcase(&amp;amp;type.) eq TEAM %then %let nvar=26;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %else %if %upcase(&amp;amp;type.) eq MISC %then %let nvar=24;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %else %let nvar=28;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; filename tempdata temp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile "c:\art\leagues_NBA_2014_&amp;amp;type..csv" delimiter=','&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MISSOVER DSD LRECL=32760;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; file tempdata dlm=',' lrecl=32760;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array vnames(&amp;amp;nvar.) $50.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; retain vnames: stopit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; informat var1-var&amp;amp;nvar. $50.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; format var1-var&amp;amp;nvar. $50.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array _vnames(&amp;amp;nvar.) $50. var1-var&amp;amp;nvar.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input var1-var&amp;amp;nvar.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _n_ eq 1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to dim(vnames);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _vnames(i)=tranwrd(_vnames(i),'%','pct');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vnames(i)=compress(translate(strip(_vnames(i)),'___',' /-'),"'");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if substr(vnames(i),1,1) eq '_' then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vnames(i)=substr(vnames(i),2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _vnames(1) eq 'Rk' then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stopit=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put ( vnames(*) ) (+0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else stopit=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if not stopit then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to dim(vnames);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _vnames(i)=tranwrd(_vnames(i),'%','pct');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vnames(i)=catx('_',translate(strip(vnames(i)),'___',' /-'),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compress(translate(strip(_vnames(i)),'___',' /-'),"'."));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _vnames(1) eq 'Rk' then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stopit=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put ( vnames(*) ) (+0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else put (_vnames(*)) (+0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc import datafile=tempdata out=&amp;amp;type. dbms=csv replace;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%importc(team)&lt;/P&gt;&lt;P&gt;%importc(misc)&lt;/P&gt;&lt;P&gt;%importc(shooting)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2014 20:03:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-import-to-read-csv-with-datarow-option/m-p/149567#M39465</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-12-16T20:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc import to read .csv with datarow= option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-import-to-read-csv-with-datarow-option/m-p/149568#M39466</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc import datafile='E:\leagues_NBA_2014_team.csv' out=misc&lt;/P&gt;&lt;P&gt;dbms=csv&lt;/P&gt;&lt;P&gt;replace;&lt;/P&gt;&lt;P&gt;datarow=3;&lt;/P&gt;&lt;P&gt;getnames=yes;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jan 2015 23:50:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-import-to-read-csv-with-datarow-option/m-p/149568#M39466</guid>
      <dc:creator>ashish_rohila</dc:creator>
      <dc:date>2015-01-09T23:50:23Z</dc:date>
    </item>
  </channel>
</rss>

