DATA Step, Macro, Functions and more

separate list by quotes

Reply
N/A
Posts: 0

separate list by quotes

I have a macro variable:

%let x = a b c d e f;

I want to use this in a couple of ways:

1: In the Keep statement - Data test; set indata(keep=&x.);

2. In the subset: Data test; set indata; if quest in(&x.);

for the scenario 2 I would need the string in %let x quoted, so it should be
%let x="a" "b" "c" "d" "e" "f";

Is there a way in SAS, I can place the quotes in datastep around the list of these macro variable values.

thanks for your help
N/A
Posts: 0

Re: separate list by quotes

Posted in reply to deleted_user
Hi,

prepare 2. macro variable

e.g.:

%let x =CUST BAB2 BAB3;

%let x2 = %sysFunC(compress(%BQUOTE(") %sysFunC(tranwrd(&x, %str( ), ",")) %BQUOTE(")));
%PUT &x2;

result:

"CUST","BAB2","BAB3"

M.
N/A
Posts: 0

Re: separate list by quotes

Posted in reply to deleted_user
Thank you very much. The solution you provided worked perfect.
Ask a Question
Discussion stats
  • 2 replies
  • 159 views
  • 0 likes
  • 1 in conversation