Learning SAS? Welcome to the exclusive online community for all SAS learners.

Macro Quotes issue:

Reply
Occasional Contributor
Posts: 11

Macro Quotes issue:

I have a macro variable let's say..

%let var="ddd.hhhjj";

I wan to extract the string after '.'  i.e.  hhhjj" and want to apply quote at starting as well, like this "hhhjj".

I tried this on EG..

%macro try;

%let var1=%sysfunc(cats('"',%substr(&var,5)));

%put &var1;

%mend;

%try

But it didn't work..

Plz suggest what's wrong with it...

thanks


Trusted Advisor
Posts: 1,137

Re: Macro Quotes issue:

Hi,

Please try the below code

%let var="ddd.hhhjj";

%macro try;

%let var1=%sysfunc(compress(%sysfunc(cats(",%substr(&var,6,5),")),','));

%put &var1;

%mend;

%try

Thanks,

Jag

Thanks,
Jag
Super Contributor
Posts: 340

Re: Macro Quotes issue:




let var="ddd.hhhjj";


%Put **&var.**;

%macro try;

*%let var1=%sysfunc(cats('"',%substr(&var,5)));

%Let var1=%scan(&var.,2,'.');

%put &var1;

%mend;

%try


Super Contributor
Posts: 275

Re: Macro Quotes issue:

%let var="ddd.hhhjj";

%let var1=%sysfunc(quote(%scan(&var,-1,%str(.""))));

%put &var1;

Occasional Contributor
Posts: 11

Re: Macro Quotes issue:

Thanks a lot to all for help Smiley Happy

Super User
Super User
Posts: 7,050

Re: Macro Quotes issue:

Why not use the DEQUOTE() function?

%let var="ddd.hhhjj";

%let var1="%scan(%qsysfunc(dequote(&var)),2,.)";

Super User
Posts: 10,035

Re: Macro Quotes issue:

Just another one .

%let var="ddd.hhhjj";

%let var1=%bquote("%scan(&var,2,.));

%put &var1 ;

Xia Keshan

Ask a Question
Discussion stats
  • 6 replies
  • 447 views
  • 1 like
  • 6 in conversation