BookmarkSubscribeRSS Feed
Tap222
Calcite | Level 5

i resolve to 8.png

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;

5 REPLIES 5
Reeza
Super User

The question is unclear. 

Tap222
Calcite | Level 5

Actually in the figure there is "I" which shows it resolve to 8.I am not able to understand why it resolves to 8.

Jagadishkatam
Amethyst | Level 16

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.

Thanks,
Jag
Reeza
Super User

@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;

 

 

 

Reeza
Super User
To find the macro definition, note the 5th line of your log, which provides the program from %cmpres auto call macro.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 3960 views
  • 1 like
  • 3 in conversation