I resolve to 8.what does it signifies?
code
(data sets frrom SAS Macro Programming Made Easy)
options mprint mlogic symbolgen;
%macro trimname(namevalue);
%cmpres(%qupcase(%sysfunc(
compress(%superq(namevalue),%str(, ),kA))))
%mend trimname;
proc tabulate data=work.ytdsales
(where=(upcase(author)=
"%trimname(%str(wright, LINDA, Lisa))"))
;
title "Title list for %trimname(%str(wright, linda, lisa))";
class booktitle datesold bookfmt;
tables booktitle=' ',
datesold="Quarter Sold" all='**Total Books Sold',
all="Books Sold"*(bookfmt all='Total')*n=' '*f=3. / misstext='0';
format datesold qtr.;
run;
The question is unclear.
Actually in the figure there is "I" which shows it resolve to 8.I am not able to understand why it resolves to 8.
The reason the I resolves to 8 is that it is set within the macro trimname to a value of 8 with %let statement. As per the image, the macro is supposed to loop if I ne 0, since 8 ne 0 the loop executes and the text is compressed to keep only the alphabets.
I am not sure of the purpose as I see the macro trimname is used to put the text in the title.
@Tap222 wrote:
Actually in the figure there is "I" which shows it resolve to 8.I am not able to understand why it resolves to 8.
Since there's no I in the code or %let, then it likely comes from the other macro CMPRES.
I do wonder why you're using both Compress function and compress macro function though.
Extracting that code provides:
%macro cmpres(text);
%*********************************************************************;
%* *;
%* MACRO: CMPRES *;
%* *;
%* USAGE: 1) %cmpres(argument) *;
%* *;
%* DESCRIPTION: *;
%* This macro returns the argument passed to it in an unquoted *;
%* form with multiple blanks compressed to single blanks and also *;
%* with leading and trailing blanks removed. *;
%* *;
%* Eg. %let macvar=%cmpres(&argtext) *;
%* *;
%* NOTES: *;
%* The %LEFT and %TRIM macros in the autocall library are used *;
%* in this macro. *;
%* *;
%*********************************************************************;
%local i;
%let i=%index(&text,%str( ));
%do %while(&i ne 0);
%let text=%qsubstr(&text,1,&i)%qleft(%qsubstr(&text,&i+1));
%let i=%index(&text,%str( ));
%end;
%left(%qtrim(&text))
%mend;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.