BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sfmeier
Obsidian | Level 7

Hi!

I am trying to import yet another .csv-File into SAS via the following code. I am getting really strange errors

although the line is supposed to end after 1. Yet it seems as if there are lots of numbers after "1." in the error report.

However if I open the .csv in the text editor, there is nothing... the first 2 lines (nr. 3 and 4) are.

Who can help?

Thx, Stefan

-------------------------------------------------------------------------------------------------------------------------------

440000836024;440-Giro-2911331-1;28336;262;197;440-K3-GIRO;0;(EUR) Euro;1

440000836024;440-Giro-2911331-1-2-Z;28336;0;0;440-K3-GIRO;0;(EUR) Euro;1

--------------------------------------------------------------------------------------------------------------------------------

15         /* Import der Adressrisiken */

16         data rwaar   (drop = positionswert) ;

17         infile 'RWAAR.csv' dsd dlm=';' firstobs=3;

18         input       fdb   :                       12.

19                      c200 :                       $65.

20                      kusa :                       $10.

21                      positionswert :              commaX18.

22                      RWA :                        commaX18.

23                      LFS :                        $20.

24                      Nominal :                    commaX18.

25                      Waehrung :                   $30.

26                      Kurs :                       commaX8.;

27         run;

NOTE: The infile 'RWAAR.csv' is:

      File Name=/export/lkri2sa/sas/user/ex26878/RWAAR.csv,

      Owner Name=ex26878,Group Name=gg_w_unix,

      Access Permission=rw-r--r--,

      File Size (bytes)=114404

NOTE: Invalid data for Kurs in line 3 72-73.

RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0                     

3   CHAR  440000836024;440-Giro-2911331-1;28336;262;197;440-K3-GIRO;0;(EUR) Euro;1. 73

    ZONE  3333333333333333246762333333323333333333333333333243244543332455224776330

    NUMR  440000836024B440D792FD2911331D1B28336B262B197B440DB3D792FB0B855290552FB1D

fdb=440000836024 c200=440-Giro-2911331-1 kusa=28336 positionswert=262 RWA=197 LFS=440-K3-GIRO Nominal=0 Waehrung=(EUR) Euro Kurs=.

_ERROR_=1 _N_=1

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

You can add the TERMSTR=CRLF option to the INFILE statement of your current code.

infile 'RWAAR.csv' dsd dlm=dlm firstobs=3 termstr=crlf;

Alternatively you can add it as a delimiter.

dlm=';'||'0d'x;

infile 'RWAAR.csv' dsd dlm=dlm firstobs=3;

View solution in original post

4 REPLIES 4
data_null__
Jade | Level 19

You appear to be reading a DOS file on UNIX.  The last charcter shown is the <CR> '0D'x

You can use the UNIX command dos2unix to convert the file to UNIX.

Or use a FILEREF with the TERMSTR opion.

FILENAME MYCSV 'RWAAR.csv' TERMSTR=CRLF;

Then use the FILEREF in PROC IMPORT.

sfmeier
Obsidian | Level 7

I do not understand a word you are saying... I am working on Windows but SAS runs on Citrix. I have no idea how and where to use unix commands, or how to access unix anyway. Is there an other way?

Tom
Super User Tom
Super User

You can add the TERMSTR=CRLF option to the INFILE statement of your current code.

infile 'RWAAR.csv' dsd dlm=dlm firstobs=3 termstr=crlf;

Alternatively you can add it as a delimiter.

dlm=';'||'0d'x;

infile 'RWAAR.csv' dsd dlm=dlm firstobs=3;

sfmeier
Obsidian | Level 7

Thx a lot, Tom! That works!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 2046 views
  • 1 like
  • 3 in conversation