BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PhilC
Rhodochrosite | Level 12

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...*/
1 ACCEPTED SOLUTION

Accepted Solutions
PhilC
Rhodochrosite | Level 12

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
:print
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.

 

 

 

 

View solution in original post

1 REPLY 1
PhilC
Rhodochrosite | Level 12

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
:print
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.

 

 

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1066 views
  • 0 likes
  • 1 in conversation