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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 5 replies
  • 3006 views
  • 1 like
  • 3 in conversation