DATA Step, Macro, Functions and more

reading data

Reply
N/A
Posts: 0

reading data

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.
Super User
Posts: 3,254

Re: reading data

Posted in reply to deleted_user
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.
N/A
Posts: 0

Re: reading data

Thanks for such a simple solution. I appreciate it.
Super Contributor
Posts: 673

Re: reading data

Posted in reply to deleted_user
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;
Ask a Question
Discussion stats
  • 3 replies
  • 131 views
  • 0 likes
  • 3 in conversation