<?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: Proc Import Generates &amp;quot;Error&amp;quot; from CSV Import in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822907#M324946</link>
    <description>It should now be attached to my original post.</description>
    <pubDate>Tue, 12 Jul 2022 17:11:30 GMT</pubDate>
    <dc:creator>A_SAS_Man</dc:creator>
    <dc:date>2022-07-12T17:11:30Z</dc:date>
    <item>
      <title>Proc Import Generates "Error" from CSV Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822881#M324932</link>
      <description>&lt;P&gt;I am importing a csv file into SAS as a part of a larger process. I am using the code below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc import datafile="/data/data.csv" 
out=test
dbms=csv replace;
GUESSINGROWS=MAX;
 run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When I run this, it generates the following Note, but it seems to act as an error would because it makes my process stop and it is underlined in red. But again, I have no "Errors" when I look at my log summary just a few warnings and notes.&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="SAS Error.PNG" style="width: 666px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73212iAADE6BA549E58364/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS Error.PNG" alt="SAS Error.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In addition, even though it stops my process it actually successfully generates the output data set. Can anyone help me understand what is going on with this and how I could potentially fix it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: The entire log is very long but I believe based on&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;'s comment I have found the more relevant part. It seems as though multiple column names are being truncated and coming in with the same name, so after the first instance of that column it generates an error. See below extended log information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;172               informat PresenceOfDiabetesType2InsulinDe best32. ;
173               informat "CurrentlyBeingTreated-DiabetesTy"N $1. ;
174               informat PresenceOfDiabetesType2NonInsuli best32. ;
NOTE: SCL source line.
175               informat "CurrentlyBeingTreated-DiabetesTy"N best32. ;
                                                               _______
                                                               485
NOTE 485-185: Informat $BEST was not found or could not be loaded.

176               informat PresenceOfDiabetesType1 best32. ;
NOTE: SCL source line.
177               informat "CurrentlyBeingTreated-DiabetesTy"N best32. ;
                                                               _______
                                                               485
NOTE 485-185: Informat $BEST was not found or could not be loaded.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Farther up in the log you can see this as well:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Name CurrentlyBeingTreated-DiabetesType2Insulin truncated to CurrentlyBeingTreated-DiabetesTy.
Name PresenceOfDiabetesType2NonInsulinDependent truncated to PresenceOfDiabetesType2NonInsuli.
Name CurrentlyBeingTreated-DiabetesType2NonInsulin truncated to CurrentlyBeingTreated-DiabetesTy.
Name CurrentlyBeingTreated-DiabetesType1 truncated to CurrentlyBeingTreated-DiabetesTy.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So thank you for potentially finding that issue, is there a way to modify proc import to allow longer variable names or something along those lines? These files are provided from a vendor so I have no control over the naming conventions and am trying to keep this as automated as possible.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2022 18:33:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822881#M324932</guid>
      <dc:creator>A_SAS_Man</dc:creator>
      <dc:date>2022-07-12T18:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import Generates "Error" from CSV Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822890#M324934</link>
      <description>&lt;P&gt;How about showing the entire log of the data step generated and executed by Proc Import.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That specific message means that the variable has already been declared as character and as such&amp;nbsp; a numeric informat, or format, cannot be used for that variable. That is what the $best indicates, that a character variable is used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2022 16:21:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822890#M324934</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-12T16:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import Generates "Error" from CSV Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822892#M324936</link>
      <description>That would be a really weird error for a standard proc import code to generate. Did you modify the code generated and then get those errors?</description>
      <pubDate>Tue, 12 Jul 2022 16:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822892#M324936</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-07-12T16:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import Generates "Error" from CSV Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822897#M324941</link>
      <description>I'm not really sure what you mean, I ran the code above in my original post and it generated that output.</description>
      <pubDate>Tue, 12 Jul 2022 16:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822897#M324941</guid>
      <dc:creator>A_SAS_Man</dc:creator>
      <dc:date>2022-07-12T16:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import Generates "Error" from CSV Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822899#M324942</link>
      <description>&lt;P&gt;Definitely need to show the full log as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;requested.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2022 16:49:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822899#M324942</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-07-12T16:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import Generates "Error" from CSV Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822902#M324943</link>
      <description>Thank you, I posted more information from the log which I think gets at what you are saying.</description>
      <pubDate>Tue, 12 Jul 2022 17:01:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822902#M324943</guid>
      <dc:creator>A_SAS_Man</dc:creator>
      <dc:date>2022-07-12T17:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import Generates "Error" from CSV Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822903#M324944</link>
      <description>&lt;P&gt;I think for a file with these type of issues I'd copy the code from the log, manually modify it to be correct including renaming variables as needed and use that to import your data instead of PROC IMPORT. This is a better approach for an automated process anyways as it will also ensure that your variables are always read correctly and the same type/format which is not guaranteed with PROC IMPORT.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2022 17:05:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822903#M324944</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-07-12T17:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import Generates "Error" from CSV Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822904#M324945</link>
      <description>&lt;P&gt;Start in the log at the Proc Import line. Copy everything through the the notes at the end of the run about observations read.&lt;/P&gt;
&lt;P&gt;Paste all of that into a text box.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The note about SCL code often means that something with a dot is used incorrectly but Proc Import generally doesn't do that.&lt;/P&gt;
&lt;P&gt;The addition of truncated variable names is not related.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would also suggest setting: Options validvarname=v7; to stop creating those name literal variables with hyphens, spaces and other non-standard characters in the variable names. It is going to be bad enough dealing with those extremely long variable names without adding the requirements to repeatedly address the "long var name"N literal on top.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2022 17:08:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822904#M324945</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-12T17:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import Generates "Error" from CSV Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822907#M324946</link>
      <description>It should now be attached to my original post.</description>
      <pubDate>Tue, 12 Jul 2022 17:11:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822907#M324946</guid>
      <dc:creator>A_SAS_Man</dc:creator>
      <dc:date>2022-07-12T17:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import Generates "Error" from CSV Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822908#M324947</link>
      <description>I didn't realize proc import was just using a data step. That is really helpful, going to do some testing on that now.</description>
      <pubDate>Tue, 12 Jul 2022 17:12:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822908#M324947</guid>
      <dc:creator>A_SAS_Man</dc:creator>
      <dc:date>2022-07-12T17:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import Generates "Error" from CSV Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822922#M324949</link>
      <description>The addition of that option actually solves the issue, repeat variable names are just imported formatted as "VAR131" or similar.</description>
      <pubDate>Tue, 12 Jul 2022 17:23:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822922#M324949</guid>
      <dc:creator>A_SAS_Man</dc:creator>
      <dc:date>2022-07-12T17:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import Generates "Error" from CSV Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822926#M324950</link>
      <description>&lt;P&gt;The problem is stemming from extremely long column headings. Note that line 173 and 175 are attempting to assign different informats and formats to multiple columns with the same name after truncation to the allowed 32 characters. I have had similar data with long column headings but never used Proc Import with Validvarname=any, which allows use of the name literals. The Import generator often fixes some of this with similar names suffixed with 1,2,3 but very long names seem to be the exceptions&amp;nbsp; You have the data data step; copy to the editor and change the names of one of the variables (in each pair, I think you have a fair number). You can drop most of the FORMAT statements and likely the Informats using BEST32. Just make sure that the Input statement has different variable names. If you remove informat statements the order of columns in the data set will change. If you are &lt;STRONG&gt;extremely careful &lt;/STRONG&gt;with editor search and replace you can find the second of each of the Informat and Input occurrences of the name and change just that one. Save the code and rerun.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;173               informat "&lt;FONT color="#008000"&gt;&lt;STRONG&gt;CurrentlyBeingTreated-DiabetesTy&lt;/STRONG&gt;&lt;/FONT&gt;"N $1. ;
174               informat PresenceOfDiabetesType2NonInsuli best32. ;
NOTE: SCL source line.
175               informat "&lt;FONT color="#008000"&gt;&lt;STRONG&gt;CurrentlyBeingTreated-DiabetesTy&lt;/STRONG&gt;&lt;/FONT&gt;"N best32. ;
                                                               _______
                                                               485
NOTE 485-185: Informat $BEST was not found or could not be loaded.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2022 17:27:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822926#M324950</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-12T17:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import Generates "Error" from CSV Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822928#M324952</link>
      <description>&lt;P&gt;Yup! It just generates the data step code. I often use it as my starting point to write code for large files (lazy/efficient) method IMO.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then modify as necessary &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I would use&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;suggestion to re-run with option validvarname=v7 to clean up some of those names as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FYI - if you're using SAS Foundation (not Studio) you can copy the code without the line numbers by holding down ALT + CNTRL while selecting the code. I use Studio so use NotePad++ to remove the line numbers these days.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2022 17:28:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822928#M324952</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-07-12T17:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import Generates "Error" from CSV Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822931#M324953</link>
      <description>I am also using studio, can you expand on how you use notepadd++ to remove line numbers?</description>
      <pubDate>Tue, 12 Jul 2022 17:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822931#M324953</guid>
      <dc:creator>A_SAS_Man</dc:creator>
      <dc:date>2022-07-12T17:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import Generates "Error" from CSV Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822934#M324954</link>
      <description>&lt;P&gt;&lt;A href="https://community.notepad-plus-plus.org/topic/15203/slick-way-to-remove-line-numbers-from-text" target="_blank"&gt;https://community.notepad-plus-plus.org/topic/15203/slick-way-to-remove-line-numbers-from-text&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2022 17:35:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822934#M324954</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-07-12T17:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import Generates "Error" from CSV Import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822949#M324959</link>
      <description>&lt;P&gt;You have discovered a bug (another bug) in PROC IMPORT.&amp;nbsp; It is triggered when using VALIDVARNAME=ANY and you have two non-standard names that are not unique in the first 32 bytes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can avoid it by setting the system option VALIDVARNAME=V7 .&lt;/P&gt;
&lt;P&gt;Here is re-producible code to demonstrate the error.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options parmcards=csv;
filename csv temp;
parmcards;
This_name_is too_long_to_be_a_NAME1,This_name_is too_long_to_be_a_NAME2
1,Albert
2,Alice
;

options validvarname=v7;
proc import datafile=csv out=v7 dbms=csv replace ;
run;
options validvarname=any;
proc import datafile=csv out=any dbms=csv replace ;
run;
options validvarname=v7;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you could use a smarter tool to generate the code to read the file.&amp;nbsp; Like&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/csv2ds.sas" target="_blank"&gt;https://github.com/sasutils/macros/blob/master/csv2ds.sas&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv2ds url "https://raw.githubusercontent.com/sasutils/macros/master/csv2ds.sas";
filename parmv url "https://raw.githubusercontent.com/sasutils/macros/master/parmv.sas";
%include parmv;
%include csv2ds;
%csv2ds(csv,out=csv2ds,replace=1)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which will try to make clearer variable names and much clearer SAS code.&lt;/P&gt;
&lt;PRE&gt;      Files\_TD24420_AMRAPY3WVP0VKU0_\#LN00064.
1538 +data csv2ds;
1539 +  infile CSV dlm=',' dsd truncover firstobs=2 ;
1540 +  length This_name_is_too_long_to_be_a_NA 8
1541 +    This_name_is_too_long_to_be_a__1 $6
1542 +  ;
1543 +  label
1544 +    This_name_is_too_long_to_be_a_NA='This_name_is too_long_to_be_a_NAME1'
1545 +    This_name_is_too_long_to_be_a__1='This_name_is too_long_to_be_a_NAME2'
1546 +  ;
1547 +  input This_name_is_too_long_to_be_a_NA -- This_name_is_too_long_to_be_a__1 ;
1548 +run;

NOTE: The infile CSV is:
      Filename=C:\Users\ABERNA~1\AppData\Local\Temp\1\SAS Temporary Files\_TD24420_AMRAPY3WVP0VKU0_\#LN00063,
      RECFM=V,LRECL=32767,File Size (bytes)=92,
      Last Modified=12Jul2022:13:56:15,
      Create Time=12Jul2022:13:56:15

NOTE: 2 records were read from the infile CSV.
      The minimum record length was 7.
      The maximum record length was 8.
NOTE: The data set WORK.CSV2DS has 2 observations and 2 variables.
&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jul 2022 18:10:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-Generates-quot-Error-quot-from-CSV-Import/m-p/822949#M324959</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-12T18:10:57Z</dc:date>
    </item>
  </channel>
</rss>

