DATA Step, Macro, Functions and more

Format PUT Output with Double Quotes, etc.

Reply
New Contributor
Posts: 3

Format PUT Output with Double Quotes, etc.

Pardon the newbie question! Thru trial and error I've gotten to this statement:

%bquote(put) "%scan(&vars,&varn)" %scan(&vars,&varn);

which gives me output like:

PATID00136201

almost what I want, but I need it formatted as:

"PATID" : "00136201"

Any help greatly appreciated!
New Contributor
Posts: 3

Re: Format PUT Output with Double Quotes, etc.

Ignore the original post. Found the trick. Replace original PUT with:

%scan(&vars,&varn)=compress(%scan(&vars,&varn),'"');
put q+(-1) "%scan(&vars,&varn)" q+(-1) ' : ' q+(-1) %scan(&vars,&varn) +(-1) q+(-1);

where q = '"'
Super Contributor
Super Contributor
Posts: 365

Re: Format PUT Output with Double Quotes, etc.

Hello Jort,

It seems to me you can also use %put insted of datastep put. It produces the same result writing to the log. For example, like this:

%let v1=PATID;
%let v2=00136201;
%put "&v1." : "&v2.";

LOG:

"PATID" : "00136201"

Sincerely,
SPR
Ask a Question
Discussion stats
  • 2 replies
  • 119 views
  • 0 likes
  • 2 in conversation