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

Hi, 

 

I'd like to store the project name from my project path into a macro variable... 

For example, let say my path is '/myprojectpath/filename'. I want to store the macro variable 'filename'. 

 

Here is the macro that I have started to develop, without success :  

%macro prgname;
%let s = &_CLIENTPROJECTPATH.;
%let delims = '\';
%let n = %sysfunc(countw(&s, &delims));
%let words = %sysfunc(scan(&s, 1:&n, &delims));
%mend prgname;


Could you highlight me ?

 

Thanks for your attention.

 

Clément

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

The scan function has an option to start searching from the end of the string, called "B". Or you could use a negative number as second argument, so something like

%let cpp = %sysfunc(dequote(&_ClientProjectPath));
%let words = %sysfunc(scan(&cpp, -1, %str(\)));

should work.

View solution in original post

4 REPLIES 4
ctisseuil
Fluorite | Level 6

Ok, 

 

I think I have a better code than the previous one but still does not work...

%let fname = %sysfunc(scan(&_CLIENTPROJECTPATH,-1,"\"));
%put &fname;

Any ideas ?

andreas_lds
Jade | Level 19

The scan function has an option to start searching from the end of the string, called "B". Or you could use a negative number as second argument, so something like

%let cpp = %sysfunc(dequote(&_ClientProjectPath));
%let words = %sysfunc(scan(&cpp, -1, %str(\)));

should work.

ctisseuil
Fluorite | Level 6

Thank you Andreas,

 

It works perfectly !

PhilC
Rhodochrosite | Level 12
%let name=%sysfunc(tranwrd(&_CLIENTPROJECTNAME,&_CLIENTPROJECTPATH,));

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 1017 views
  • 0 likes
  • 3 in conversation