BookmarkSubscribeRSS Feed
baharmollex
Fluorite | Level 6

I know for the fact I have 1000 obs

when I run my code which is the following in the output I see some of rows are missing and I only have up 821 rows.

libname blood "~/";

data blood.one;
Infile "~/blood.txt";
input
@1 obs 4.
@6 Gender $7.
@12 BloodType $3.
@15 AgeGroup $7.
@22 WBC 4.
@26 RBC 7.
@33Chol 4.
;
run;
4 REPLIES 4
Tom
Super User Tom
Super User

What do the NOTEs in the SAS log say?

 

If you are going to use fixed format input statements like that then you must use the TRUNCOVER option on the INFILE statement.  

infile "~/blood.txt" truncover;

With the default FLOWOVER option when you read past the end of the line the INPUT statement will hunt for the field on the next line.  With the older less useful MISSOVER option if there are between 33 and 36 characters on the line then CHOL will be missing because there are not four characters for the 4. informat to read.

baharmollex
Fluorite | Level 6

sas.jpg

This is my raw data, the last column is Chol length is 3 but when I change it to 2 I see 1000 values.

I tried truncovern as well. Nothing changed. can you please help?

baharmollex
Fluorite | Level 6
NOTE: Invalid data for RBC in line 88 26-32.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
88 88 Female A Old 10260 5.63 296 36
obs=88 Gender=Female BloodType=A AgeGroup=Old WBC=1026 RBC=. Chol=2 _ERROR_=1 _N_=88
NOTE: Invalid data for RBC in line 937 26-32.
937 937 Male A Young 10550 5.41 . 34
obs=937 Gender=Male BloodType=A AgeGroup=Young WBC=1055 RBC=. Chol=. _ERROR_=1 _N_=937
NOTE: 1000 records were read from the infile "~/blood.txt".
The minimum record length was 34.
The maximum record length was 36.
NOTE: The data set BLOOD.ONE has 1000 observations and 7 variables.
NOTE: DATA statement used (Total process time):
 
Tom
Super User Tom
Super User

READ THE NOTES IN THE SAS LOG.

 

If you want help interpreting them then copy the lines from the SAS log for the data step that is reading the text file.  Start with the DATA statement and include all of the notes after the end of the stop.

 

Paste them into the box that opens when you click on the Insert Code icon (the icon that looks like the characters < / > ).  Please do not post text as photographs.

 

Perhaps SAS is trying to read the end of line characters as part of the data of the line.

Try adding the option TERMSTR=CRLF to the INFILE statement.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1102 views
  • 1 like
  • 2 in conversation