I think I've read someone suggest SED script without posting a script. Are there any other ideas? I am familiar with SED, but I'm failing to make it work.
I want to process a set of files and remove the line with "GOPTIONS ACCESSIBLE;" and all lines before, as well as the line with "GOPTIONS NOACCESSIBLE;" and all lines after.
/* ----------------------------------------
Code exported from SAS Enterprise Guide
DATE: Wednesday, November 28, 2018 TIME: 10:33:05 AM
/*... blah blah...*/
GOPTIONS ACCESSIBLE;
/* ***************************** */
/* My Code, which I want to keep */
/* ***************************** */
%Macro Table_Lookup(command,result);
/* etc. etc. */
%mend;
GOPTIONS NOACCESSIBLE;
%LET _CLIENTTASKLABEL=;
/*... blah blah...*/
Ok I figured it out.
Removes the header defined by the last line which is a match for "STRING IN THE LAST LINE OF THE HEADER" and the footer defined by the first string which is a match to "STRING IN THE BEGINNING OF THE FOOTER".
Its up to the user to find appropriate and unique match strings to make this work.
/STRING IN THE LAST LINE OF THE HEADER/h
/STRING IN THE BEGINNING OF THE FOOTER/bbeginprint
x
/STRING IN THE BEGINNING OF THE FOOTER/bprint
d
x
p
d
:beginprint
h
d
Using sed command line:
sed -i -n -f "script file_name.sed" "file name.sas"
The SED version I am using is GNU SED version 4.2.1, on Windows 10.
Ok I figured it out.
Removes the header defined by the last line which is a match for "STRING IN THE LAST LINE OF THE HEADER" and the footer defined by the first string which is a match to "STRING IN THE BEGINNING OF THE FOOTER".
Its up to the user to find appropriate and unique match strings to make this work.
/STRING IN THE LAST LINE OF THE HEADER/h
/STRING IN THE BEGINNING OF THE FOOTER/bbeginprint
x
/STRING IN THE BEGINNING OF THE FOOTER/bprint
d
x
p
d
:beginprint
h
d
Using sed command line:
sed -i -n -f "script file_name.sed" "file name.sas"
The SED version I am using is GNU SED version 4.2.1, on Windows 10.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.