DATA Step, Macro, Functions and more

Extracting records with in particular string

Reply
Frequent Contributor
Posts: 79

Extracting records with in particular string

Could somebody please give me some thoughts what do loop I should code to extract the data between String PROF so basically the output dataset should have records which are between "PROF" string as many time as it appear until it reach End of file..

 

TESTING DATA WHICH IS NOT VALID
TESTING DATA WHICH IS NOT VALID

TESING DATA             PROF
YES THIS IS A RECORD
YES THIS IS ANOTHER RECORD
DXXXXXXXXXXXXX
XXXXXXXXXXXXXXX

TESTING DATA           PROF
YES THIS IS A RECORD
YES THIS IS ANOTHER RECORD
DXXXXXXXXXXXXX
XXXXXXXXXXXXXXX

TESTING DATA WHICH IS NOT VALID
TESTING DATA WHICH IS NOT VALID

SAS Moderator
Posts: 70

Re: Extracting records with in particular string [how to improve your question]

Hello @rkumar23,


Your question requires more details before experts can help. Can you revise your question to include more information? 

 

Review this checklist:

  • Specify a meaningful subject line for your topic.  Avoid generic subjects like "need help," "SAS query," or "urgent."
  • When appropriate, provide sample data in text or DATA step format.  See this article for one method you can use.
  • If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition. Use the Photos button to include the image in your message.
    use_buttons.png
  • It also helps to include an example (table or picture) of the result that you're trying to achieve.

To edit your original message, select the "blue gear" icon at the top of the message and select Edit Message.  From there you can adjust the title and add more details to the body of the message.  Or, simply reply to this message with any additional information you can supply.

 

edit_post.png

SAS experts are eager to help -- help them by providing as much detail as you can.

 

This prewritten response was triggered for you by fellow SAS Support Communities member @Reeza

.
Super User
Posts: 13,950

Re: Extracting records with in particular string

Show what you output should look like.

It really helps to provide an example of actual data in the form of a data step. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

Ask a Question
Discussion stats
  • 2 replies
  • 104 views
  • 0 likes
  • 3 in conversation