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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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
  • 2195 views
  • 1 like
  • 2 in conversation