Can someone explain to me why I'm getting the warning that I'm getting? I've tried reading other posts and can't find a solution.
At various times throughout a program, I am passing a parameter that is typically 2-6 characters plus a 3-digit number through a macro. In the macro, I am trying to extract just the digits. I'm trying to use the A modifier in the compress() function, but I get a warning that appears twice with every pass of the macro:
WARNING: In a call to the COMPRESS function or routine, the modifier "'" not valid.
The warning isn't influencing the output (as you can see in the log), but I still want to understand the warning:
6968 %macro check (dsin=);
6969 %let checkval=%sysfunc(compress(&dsin.,'','a'));
6970 %put CHECKVAL=~~~&checkval.~~~;
6971 %mend check;
6972
6973
6974 %check (dsin=AE001);
WARNING: In a call to the COMPRESS function or routine, the modifier "'" not valid.
WARNING: In a call to the COMPRESS function or routine, the modifier "'" not valid.
CHECKVAL=~~~001~~~Here is a very small portion of the macro I am running with various test cases for the input parameter:
%macro check (dsin=);
%let checkval=%sysfunc(compress(&dsin.,'','a'));
%put CHECKVAL=~~~&checkval.~~~;
%mend check;
%check (dsin=AE001);
%check (dsin=AE002);
%check (dsin=AE003);
%check (dsin=AE004);
%check (dsin=AE005);
%check (dsin=CFAE003);
%check (dsin=AE003);
%check (dsin=AE004);
%check (dsin=AE011);
%check (dsin=BF012);
%check (dsin=ZQ014);
%check (dsin=LKNM016);
This works for me
%macro check (dsin=);
%let checkval=%sysfunc(compress(&dsin,,ai));
%put CHECKVAL=~~~&checkval.~~~;
%mend check;
%check (dsin=AE001)
I added i modifier to your a to ignore case sensitive operation
syntax check
Try-
6968 %macro check (dsin=);
6969 %let checkval=%sysfunc(compress(&dsin., ,a));
6970 %put CHECKVAL=~~~&checkval.~~~;
6971 %mend check;
6972
6973
6974 %check (dsin=AE001);
This works for me
%macro check (dsin=);
%let checkval=%sysfunc(compress(&dsin,,ai));
%put CHECKVAL=~~~&checkval.~~~;
%mend check;
%check (dsin=AE001)
I added i modifier to your a to ignore case sensitive operation
Oh my goodness. It was just the single quotes around the A modifier? I was trying so many different things like quotes around the &dsin. parameter or quotes around blank space in the 2nd compress parameter. Nothing was working, but removing the quotes around the modifier did the trick. Thanks!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.