BookmarkSubscribeRSS Feed
Peter_C
Rhodochrosite | Level 12
this question occurred to me when reading the following, quoted from "Problem Note 40031: Single quotation marks have been added to internal macros in SAS® Enterprise Guide®" at http://support.sas.com/kb/40/031.html
" ....... for example, &_clientapp resolves to 'SAS Enterprise Guide', but, in earlier versions, the same macro variable resolves to SAS Enterprise Guide.

To remove the quotation marks, use %SYSFUNC, for example:

title "%sysfunc(compress(&_clientapp,%str(%')))".


This solution is provided as an example, but would you like to comment on the more general application of [pre] %sysfunc(compress(&_some_macro_var_,%str(%')))[/pre] compared with this alternative[pre] %sysfunc(dequote(&_some_macro_var_))[/pre] ??

well we are a discussion forum 😉

peterC
4 REPLIES 4
data_null__
Jade | Level 19
A subtle difference occurs if the first character of the value that is operated on by DEQUOTE is not a quote then the function does not remove any quotes. Admittedly you have to work pretty hard to make that happen.

The advantage of DEQUOTE is that is properly handles imbedded quotes and works equally well for single and double quotes. Plus with DEQUOTE you don't have to remember how to used unmatched quotes [pre]%STR(%')[/pre]
I'm not familiary with the "EG 12" but I expected either method would return the correct DEQUOTED value.



[pre]
378 data _null_;
379 infile cards eof=eof;
380 input m $char40.;
381 call symput(cats('M',_n_),m);
382 list;
383 return;
384 eof:
385 call symputX('M0',_n_-1);
386 stop;
387 cards;

RULE: ----+----1----+----2----+----3----+----4
388 'SAS Enterprise Guide'
389 'SAS Enterprise Guide'
390 'SAS Enterprise''s Guide'
391 "SAS Enterprise's Guide"
392 "SAS Enterprise's Guide"

393 ;;;;
394 run;
395 %macro p;
396 %do i = 1 %to &m0;
397 %put NOTE: \&&M&I\;
398 %put NOTE- \%qsysfunc(compress(%bquote(&&m&i),%str(%')))\;
399 %put NOTE- \%qsysfunc(dequote(%bquote(&&m&i)))\;
400 %end;
401 %mend p;
402 %p
NOTE: \'SAS Enterprise Guide' \
\SAS Enterprise Guide \
\SAS Enterprise Guide\
NOTE: \ 'SAS Enterprise Guide' \
\ SAS Enterprise Guide \
\ 'SAS Enterprise Guide' \
NOTE: \'SAS Enterprise''s Guide' \
\SAS Enterprises Guide \
\SAS Enterprise's Guide\
NOTE: \"SAS Enterprise's Guide" \
\"SAS Enterprises Guide" \
\SAS Enterprise's Guide\
NOTE: \ "SAS Enterprise's Guide" \
\ "SAS Enterprises Guide" \
\ "SAS Enterprise's Guide" \
[/pre]
Peter_C
Rhodochrosite | Level 12
bemused by %put NOTE- effect! [pre] %put NOTE- ...........[/pre] not printing NOTE in the log.
Is there an explanation of this functionality anywhere?
data_null__
Jade | Level 19
From documentation for %PUT

The %PUT statement displays text in different colors to generate messages that look like ERROR, NOTE, and WARNING messages generated by SAS. To display text in different colors, the first word in the %PUT statement must be ERROR, NOTE, or WARNING, followed immediately by a colon or a hyphen. You may also use the national-language equivalents of these words. When you use a hyphen, the ERROR, NOTE, or WARNING word is blanked out.

Works for "regular" put and putlog too.
Peter_C
Rhodochrosite | Level 12
pardon me, I should have done a better job of ... rtfm

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3095 views
  • 1 like
  • 2 in conversation