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.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.