BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello SAS Users,

I have hundreds of data sets that have orderly arranged columns of data. However, these files differ in total number of observations. The problem I have is that at the end of the final data line plus two blank lines for each data file, there is a description of each variable (about 15) in the data set. As you could imagine its very cumbersome to remove that information from each of the several hundred files. Clearly, SAS would throw out an error when it reads those variable descriptions because they would not conform to my description in the INPUT statement, which works out well for the data lines. Is there a way I can read only up to the last data line while ignoring or deleting the variable descriptions? I would really appreciate your help.
3 REPLIES 3
SASKiwi
PROC Star
If the only blank lines in your files are at the end before the descriptions then you could check for a blank line and then stop like this:

data test;
infile xxxx;
input @1 check $1. @;
if check ne '' then input ;
else stop;
run;

The trailling @ sign will hold the current record for your full INPUT statement.
deleted_user
Not applicable
Thanks for such a simple solution. I appreciate it.
SASPhile
Quartz | Level 8
data test;
x = "A"; y = 1; output;
x = " "; y = 1; output;
x = " "; y = .; output;
x = "B"; y = 1; output;
x = "C"; y = 1; output;
run;
data test1;
set test;
if not missing(compress(cats(of _all_),'.'));
run;

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
  • 3 replies
  • 634 views
  • 0 likes
  • 3 in conversation