<?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: Importing CVS file in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/308866#M61213</link>
    <description>&lt;P&gt;Why did you post an Excel workbook if your source is a CSV file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 02 Nov 2016 19:54:55 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2016-11-02T19:54:55Z</dc:date>
    <item>
      <title>Importing CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/308826#M61207</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lase week I posted a question on importing CSV file. Some one posted &amp;nbsp;some suggestions. But it didnot help. I did some work and have some questions on it.&lt;/P&gt;
&lt;P&gt;In the dataset, why it showing only first two variable names and rest as VAR3 to VAR13. The third variable name is shown&amp;nbsp;under second varianle.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am attaching the csv file that I am trying to download. Please help how to get the dataset with all variable names and without any errors&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code from log when I downloaded maually:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data WORK.dv ;&lt;BR /&gt;%let _EFIERR_ = 0; /* set the ERROR detection macro variable */&lt;BR /&gt;infile 'C:\Users\rr\Desktop\PEC.csv' delimiter = ',' missover DSD lrecl=32767&lt;BR /&gt;firstobs=2 ;&lt;BR /&gt;informat Deviation__ best32.;&lt;BR /&gt;informat Screening $6. ;&lt;BR /&gt;informat VAR3 best32. ;&lt;BR /&gt;informat VAR4 $171. ;&lt;BR /&gt;informat VAR5 $9. ;&lt;BR /&gt;informat VAR6 DATE8. ;&lt;BR /&gt;informat VAR7 DATE9. ;&lt;BR /&gt;informat VAR8 $5. ;&lt;BR /&gt;informat VAR9 $32. ;&lt;BR /&gt;informat VAR10 $9. ;&lt;BR /&gt;informat VAR11 $2. ;&lt;BR /&gt;informat VAR12 $2. ;&lt;BR /&gt;informat VAR13 $4. ;&lt;BR /&gt;format Deviation__ best12. ;&lt;BR /&gt;format Screening $6. ;&lt;BR /&gt;format VAR3 best12. ;&lt;BR /&gt;format VAR4 $171. ;&lt;BR /&gt;format VAR5 $9. ;&lt;BR /&gt;format VAR6 DATE8. ;&lt;BR /&gt;format VAR7 DATE9. ;&lt;BR /&gt;format VAR8 $5. ;&lt;BR /&gt;format VAR9 $32. ;&lt;BR /&gt;format VAR10 $9. ;&lt;BR /&gt;format VAR11 $2. ;&lt;BR /&gt;format VAR12 $2. ;&lt;BR /&gt;format VAR13 $4. ;&lt;BR /&gt;input&lt;BR /&gt;Deviation__ $&lt;BR /&gt;Screening $&lt;BR /&gt;VAR3&lt;BR /&gt;VAR4 $&lt;BR /&gt;VAR5 $&lt;BR /&gt;VAR6&lt;BR /&gt;VAR7&lt;BR /&gt;VAR8 $&lt;BR /&gt;VAR9 $&lt;BR /&gt;VAR10 $&lt;BR /&gt;VAR11 $&lt;BR /&gt;VAR12 $&lt;BR /&gt;VAR13 $&lt;BR /&gt;;&lt;BR /&gt;if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;I also tried this code, which resulted in error message "Import procedure not successful."&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc import datafile="C:\Users\nn\Desktop\pp.csv" DBMS=csv out=mm;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; guessingrows = 100;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 20:45:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/308826#M61207</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2016-11-02T20:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: Importing CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/308829#M61208</link>
      <description>&lt;P&gt;Attach a CSV file by changing the extension to txt.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many people won't open an XLSX file.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 18:56:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/308829#M61208</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-02T18:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Importing CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/308863#M61212</link>
      <description>&lt;P&gt;I assume you have no column labels in your excel/csv file columnns C to M,&lt;/P&gt;
&lt;P&gt;or labels were non valid SAS names.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 19:47:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/308863#M61212</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-02T19:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Importing CVS file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/308866#M61213</link>
      <description>&lt;P&gt;Why did you post an Excel workbook if your source is a CSV file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 19:54:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/308866#M61213</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-11-02T19:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: Importing CVS file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/308870#M61215</link>
      <description>&lt;P&gt;Much easier to read a XLSX file than a CSV (as long as you are using a recent version of SAS).&lt;/P&gt;
&lt;P&gt;But your column headers do not make very good variable names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;8     libname x xlsx "&amp;amp;path\PEC1.xlsx";
NOTE: Libref X was successfully assigned as follows:
      Engine:        XLSX
      Physical Name: C:\Users\XXXXXX\Downloads\PEC1.xlsx
9     proc copy inlib=x outlib=work; run;

NOTE: Copying X.PEC to WORK.PEC (memtype=DATA).
NOTE:    Variable Name Change.  Deoooooon # -&amp;gt; Deoooooon__
NOTE:    Variable Name Change.  Sooooning 
N00ber -&amp;gt; Sooooning___N00ber
NOTE:    Variable Name Change.  Sooooot ID                     N -&amp;gt; Sooooot_ID_____________________N
NOTE:    Variable Name Change.  Deoooooooon of Devooooon - Phooo -&amp;gt; Deoooooooon_of_Devooooon___Phooo
NOTE:    Variable Name Change.  Stooy Vioot Doy -&amp;gt; Stooy_Vioot_Doy
NOTE:    Variable Name Change.  Date Devioooon Ocooored -&amp;gt; Date_Devioooon_Ocooored
NOTE:    Variable Name Change.  Dooe PO Ideooooood by COA -&amp;gt; Dooe_PO_Ideooooood_by_COA
NOTE:    Variable Name Change.  Clasooooooooon (Mooor or Mooor) -&amp;gt; Clasooooooooon__Mooor_or_Mooor_
NOTE:    Variable Name Change.  Rooorted to RA -&amp;gt; Rooorted_to_RA
NOTE:    Variable Name Change.  Rooorted to IRB/IEC -&amp;gt; Rooorted_to_IRB_IEC
NOTE:    Variable Name Change.  Aoooon roooired -&amp;gt; Aoooon_roooired
NOTE: BUFSIZE is not cloned when copying across different engines. System Option for BUFSIZE was used.
NOTE: The import data set has 1 observations and 13 variables.
NOTE: There were 1 observations read from the data set X.PEC.
NOTE: The data set WORK.PEC has 1 observations and 13 variables.
NOTE: PROCEDURE COPY used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds


10    proc print; run;

WARNING: Data too long for column "Deoooooooon_of_Devooooon___Phooo"; truncated to 103 characters to fit.
NOTE: There were 1 observations read from the data set WORK.PEC.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Nov 2016 20:05:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/308870#M61215</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-11-02T20:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: Importing CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/308886#M61220</link>
      <description>&lt;P&gt;There are&amp;nbsp;2 main reasons you would get VARx for variables when using proc import for a csv and all are related to the content of the column heading.&lt;/P&gt;
&lt;P&gt;1) Missing&amp;nbsp; if your csv header row has any consecutive commas not enclosed in quotes then there is nothing SAS sees to assign the variable and basically uses VAR plus the column number.&amp;nbsp; I suspect that your header looked like:&lt;/P&gt;
&lt;P&gt;Deviation&amp;nbsp; ,Screening,,,,,,,&lt;/P&gt;
&lt;P&gt;if you open the CSV in Wordpad.&lt;/P&gt;
&lt;P&gt;2) The text of the column heading is identical to another column and exceeds 32 characters. Something&lt;/P&gt;
&lt;P&gt;"CLIENT_PERSONAL_LANGUAGE_0_FIRST_INTAKE","CLIENT_PERSONAL_LANGUAGE_0_FIRST_UPDATE"&lt;/P&gt;
&lt;P&gt;The underscore after FIRST is at position 33 so the first 32 characters are the same. Since SAS has a current limit of 32 characters for a variable name the first one gets truncated to 32 characters. The second gets VARx named as SAS doesn't attempt to guess how to truncate an supply suffix.&lt;/P&gt;
&lt;P&gt;Note that if you have columns with the same name in your CSV such as INCOME you can end up with INCOME, INCOME2, INCOME3 because SAS has room to add the counter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may also have some interesting side effects if your column headings have many characters that are not allowed in SAS variable names as they will all be replaced by underscores.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One of the major advantages of writing, or modifying Proc Import generated code, is that YOU can assign meaningful or at least short variable names and add LABEL statements to provide more text for documenting what that variable means.&lt;/P&gt;
&lt;P&gt;I routinely deal with exported data that has column headings like "When is this information being collected" and assign a variable name like CollectionDate (if a date&amp;nbsp;variable)&amp;nbsp;or CollectionOccasion if something like Intake or Update values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 21:24:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/308886#M61220</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-11-02T21:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: Importing CVS file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/309071#M61224</link>
      <description>&lt;P&gt;Sorry. I could not upload the CSV file.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 15:48:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/309071#M61224</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2016-11-03T15:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Importing CVS file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/309075#M61225</link>
      <description>&lt;P&gt;You don't even need to upload a CSV file. Just copy some sample lines and paste them into the editor. &amp;nbsp;Open the file with WordPad or NotePad or other text editor tool. &amp;nbsp;Copy a the header row and a couple of data rows and paste them into a code block in your message. Like this:&lt;/P&gt;
&lt;PRE&gt;Id,Var1,Var2
1234,3.4,Great
2345,5.6,Terrible&lt;/PRE&gt;
&lt;P&gt;In reality just going through the process to attempt to do that will probably show you the answer to your original question.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 15:57:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/309075#M61225</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-11-03T15:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Importing CVS file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/309079#M61226</link>
      <description>&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Deviation #,"Screening&lt;BR /&gt;Number",Subject ID Number,Description of Deviation - Physical Examination,Study Visit Day,Date Deviation Occurred,Date PD Identified by CRA,Classification (Minor or Major),Category,Outcome,Reported to RA,Reported to IRB/IEC,Action required&lt;BR /&gt;1,Q-0000,1000,"During the screening on 1JUN11 the alcohol breath test was not performed, however the subject returned to the clinic to perform this assessment on the 10th of June 2006.",Screening,3-Jun-06,23-Jun-06,Minor,alcohol breath test,continued,NA,NA,None&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 16:04:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/309079#M61226</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2016-11-03T16:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Importing CVS file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/309083#M61227</link>
      <description>&lt;P&gt;Looks like your CSV file has a line break in the middle of the header for the second column. &amp;nbsp;Hence the confusion since it looks like two lines. &amp;nbsp;If you generated this on Windows then there is a chance that you can use the TERMSTR= option to get SAS to find the lines properly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename myfile  'myfilename.csv' termstr=crlf ;

proc import datafile=myfile ....  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Nov 2016 16:18:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-CSV-file/m-p/309083#M61227</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-11-03T16:18:59Z</dc:date>
    </item>
  </channel>
</rss>

