Reputation: 43
I'm trying to import and clean some file where the first rows of column 1 contains description and column names. the data begins after the row containing "BEGINDATA". Is it possible to search sas table for "BEGINDATA" and assign the row number to a macro variable? In the next data step I could use firstobs=macro variable to load only data.
Thanks for any hint!
Upvotes: 0
Views: 738
Reputation: 51621
Not much you can do after it is already "imported". But if your source file is just a text file then your data step that reads it can just skip the prefix in the same step that reads the data.
data want;
infile 'myfile.csv' dsd truncover ;
input test :$20. @1 @;
do while (test ne 'BEGINDATA');
input ;
input test :$20. @1 @;
end;
* Code to read the actual data lines ;
run;
Upvotes: 0
Reputation: 12909
Certainly! See this example.
/* Generate example data */
data have;
do i = 1 to 10000;
if(i = 100) then description = 'BEGINDATA';
else call missing(description);
value = rand('uniform');
output;
end;
drop i;
run;
/* Get row where the data begins. Only keep the description variable
to reduce the size of the PDV */
data _null_;
set have(keep=description);
if(description = 'BEGINDATA') then do;
call symputx('startrow', _N_, 'G');
stop;
end;
run;
/* Read from the data start row */
data want;
set have(firstobs=&startrow.);
run;
Upvotes: 1