Whilst I normally advise against proc import, in this case it may be the easiest. As for the file, you can pretty easily read it in and drop those line where first line="#".
Something like this:
data _null_;
infile "xyz.txt";
file "xyz.txt";
input buffer $varying256.;
if substr(buffer,1,1)="#" then delete;
else put buffer;
run;
How to set the length variable after $varying in this case? sorry I am a SAS newbie. "input buffer $varying256.;" get an error as
ERROR: Variable name containing length expected after $VARYING
Well the point being is that you are not actually creating your dataset at this point. The example is present to remove any lines with the first character being a hash:
data _null_;
length buffer $2000.;
infile "s:\temp\rob\a.txt";
file "s:\temp\rob\a.txt";
input buffer $;
if substr(buffer,1,1)="#" then delete;
else put buffer;
run;
The file a.txt has 3 rows to start, one with a hash as first character, after program is run there are only two rows. The demonstrates how to remove the header information from your file.
It works, but still need to add some codes to do that for all the 80 files,output file name sepcified after file stament can not be the same as the input file after infile satment, otherwise the file will not be updated.
RW9, Thanks for you explains.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.