BookmarkSubscribeRSS Feed
fengyuwuzu
Pyrite | Level 9

either by proc import or data step with infile to read in .csv files, I notice that the last line in the data sets is blank.

Actually the last line in the .csv file has no values at all. Somehow when SAS read the data, it stops at the line below the last line in CSV.

 

How to solve this issue? Thanks.

5 REPLIES 5
LinusH
Tourmaline | Level 20
Are you sure that there are no LF/CR at your last lkne with values?
Data never sleeps
PGStats
Opal | Level 21

With data step import, you could add the statement

 

if not missing(cats(of _all_));

to remove any line (observation) that is totally empty (missing).

PG
Babloo
Rhodochrosite | Level 12

Could you please what 'cats(of _all_)' will do in following if clause?

 

if not missing(cats(of _all_));

 

Kurt_Bremser
Super User
if not missing(cats(of _all_));

That only works if all variables are character, as numeric variables will render a dot in the cats(of _all), causing the string to be non-missing.

In order for this to work,

options missing = ' ';

needs to be set.

Kurt_Bremser
Super User

fengyuwuzu wrote:

either by proc import or data step with infile to read in .csv files, I notice that the last line in the data sets is blank.

Actually the last line in the .csv file has no values at all.


 

That is as expected. An empty line in a .csv file will cause the input statement to read nothing, so the variables stay "missing" for this iteration of the data step.

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
  • 5 replies
  • 1231 views
  • 1 like
  • 5 in conversation