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.

 

 

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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