DATA Step, Macro, Functions and more

Need to extract a char between special char from a string

Accepted Solution Solved
Reply
Contributor
Posts: 66
Accepted Solution

Need to extract a char between special char from a string

 

Hi Experts,

 

I am trying to extract the list of SAS program names from a dataset, i have hundreds of them and the special chars are present at

 

for example

 

/xxxx/abcde/abcdefgh.sas

/xxxx/abcde/lkml/abcdefguh.sas

/xxxx/abcde/lkml555/abguh.sas

 

I am trying to get the output as

abcdefgh.sas

abcdefguh.sas

abguh.sas

 

 

 


Accepted Solutions
Solution
‎06-03-2016 02:20 PM
Contributor
Posts: 66

Re: Need to extract a char between special char from a string

Posted in reply to Bruno_SAS

Hi,

 

Thank you!!!

I was not able to remember this.

View solution in original post


All Replies
SAS Super FREQ
Posts: 708

Re: Need to extract a char between special char from a string

Posted in reply to santosh_pat69

Hi

 

The SCAN function can help you with that, see example below.

data want;
  infile cards;
  input
    pgmname : $256.
  ;
  justPgm = scan(pgmname, -1, "/");
cards;
/xxxx/abcde/abcdefgh.sas
/xxxx/abcde/lkml/abcdefguh.sas
/xxxx/abcde/lkml555/abguh.sas ;

check the doc for more details.

 

Bruno

Solution
‎06-03-2016 02:20 PM
Contributor
Posts: 66

Re: Need to extract a char between special char from a string

Posted in reply to Bruno_SAS

Hi,

 

Thank you!!!

I was not able to remember this.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 226 views
  • 0 likes
  • 2 in conversation