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.

 

 

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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