Help using Base SAS procedures

SAS to delete header and trailer in a file

Reply
N/A
Posts: 0

SAS to delete header and trailer in a file

Hi,

I am new to SAS and have a question for all the SAS guru's out there. I am trying to delete the header and trailer record
of a data file in sas and then continue with some other audits on that file. The header, the first record of the file is listed as Header90900.. and the trailer, the last record is listed as Trailer9900.



Can you please suggest the different ways how I could delete these in SAS ?



Example of file:


Header90900

565 ff dfdd dfdd 878

898 rtr sds sss 0909

....

...

Trailer9900





Note: The header and trailer have random numbers after them but they begin with the key words Header and Trailer.
Super Contributor
Super Contributor
Posts: 3,174

Re: SAS to delete header and trailer in a file

Within the DATA step execution process, you can use the INFILE parameter END= keyword to detect end-of-file (last record encountered). As well, for the initial pass of a DATA step execution, one technique is to use a RETAIN statement to set your own variable with a default value of 1 and then reset it to a zero. So, for each of these conditions, you would use a RETURN, DELETE or do not issue an OUTPUT or PUT _INFILE_, depending on your particular SAS program execution requirements.

The SAS support http://support.sas.com/ website has SAS-host documentation and also supplemental technical / conference topic papers -- you can either use the website SEARCH facility or here is a Google advanced search argument to locate some pertinent reference material on this topic:

sas data step programming site:sas.com

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 1 reply
  • 592 views
  • 0 likes
  • 2 in conversation