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

So I have a .txt dataset with a space delimiter, but multiple spaces in one column, like so:

car                             Weight  Disp.   Mileage Fuel  Type 
               Eagle Summit 4   2560    97      33 3.030303 Small
                Ford Escort 4   2345   114      33 3.030303 Small
               Ford Festiva 4   1845    81      37 2.702703 Small
.
.
.
          Ford Thunderbird V6   3610   232      23 4.347826 Medium
       	     Hyundai Sonata 4   2885   143      23 4.347826 Medium
                 Mazda 929 V6   3480   180      21 4.761905 Medium
       	     Nissan Maxima V6   3200   180      22 4.545455 Medium
   Oldsmobile Cutlass Ciera 4   2765   151      21 4.761905 Medium

I thought I took care of it by specifying the length of the 'car' variable, and my code looks like this:

DATA car; 
	INFILE "/folders/myfolders/sasuser.v94/carfin.txt"
	FIRSTOBS = 2
	DLM = ''
	MISSOVER;
	LENGTH car $ 30;
	INPUT car & weight disp mileage fuel type $;
RUN;

And this happens:

Screen Shot 2020-04-09 at 10.37.21 AM.png

 

Lines 43, 44, 46, and 48 are how this data is supposed to look like. You can see what they look like in the original .txt above.

Literally only these 2 rows are like this, every other one is fine.

 

Here is what the log looks like:

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         DATA car;
 74         INFILE "/folders/myfolders/sasuser.v94/carfin.txt"
 75         FIRSTOBS = 2
 76         DLM = ''
 77         MISSOVER;
 78         LENGTH car $ 30;
 79         INPUT car & weight disp mileage fuel type $;
 80         RUN;
 
 NOTE: The infile "/folders/myfolders/sasuser.v94/carfin.txt" is:
       Filename=/folders/myfolders/sasuser.v94/carfin.txt,
       Owner Name=sasdemo,Group Name=sas,
       Access Permission=-rw-rw-r--,
       Last Modified=09Apr2020:10:26:53,
       File Size (bytes)=4125
 
 NOTE: Invalid data for weight in line 46 14-20.
 NOTE: Invalid data for disp in line 46 22-27.
 RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0                      
 
 46  CHAR         .     Hyundai Sonata 4   2885   143      23 4.347826 Medium 66
     ZONE  222222202222247766662566676232223333222333222222332323333332466676
     NUMR  0000000900000895E41903FE1410400028850001430000002304E3478260D5495D
 car= weight=. disp=. mileage=4 fuel=2885 type=143 _ERROR_=1 _N_=45
 NOTE: Invalid data for weight in line 48 14-19.
 NOTE: Invalid data for disp in line 48 21-26.
 NOTE: Invalid data for mileage in line 48 28-29.
 
 48  CHAR         .     Nissan Maxima V6   3200   180      22 4.545455 Medium 66
     ZONE  222222202222246776624676662532223333222333222222332323333332466676
     NUMR  0000000900000E9331E0D189D106600032000001800000002204E5454550D5495D
 car= weight=. disp=. mileage=. fuel=3200 type=180 _ERROR_=1 _N_=47
 NOTE: 60 records were read from the infile "/folders/myfolders/sasuser.v94/carfin.txt".
       The minimum record length was 63.
       The maximum record length was 67.
 NOTE: The data set WORK.CAR has 60 observations and 6 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 81         
 82         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 94  

I'm using SAS University Edition and MacOS Mojave.

 

Thank you for reading through this and for any advice!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Why do those two lines have tabs in them?

Did you trying adding EXPANDTABS option to your INFILE statement?

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Why do those two lines have tabs in them?

Did you trying adding EXPANDTABS option to your INFILE statement?

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 465 views
  • 1 like
  • 2 in conversation