BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SASAna
Quartz | Level 8

Hello SAS users,

 

Need help with compressing the dots in the macro variables of DX1 to DX50. and i am getting the below error

 

code  -

 

%Do i=1 %to 50;

%if %sysfunc(compress(DX&i) ,'.')) in ( ' DS123')  %then output;

 

Error - 

 

ERROR: Format name '.' not found or the width and/or decimal specified for the format used are out of range.

 

Thanks,

Ana

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

That's what you get when you try to do data processing in the macro language. That many macro variables is often a sign of a not well designed issue.

And the macro language treats literal characters a bit differently than the data step and quotes are often inappropriate.

 

You are "compressing" the literal value DX1 for instance. So there is no "space"  or "." to begin with.

Is DX&i a macro variable? or a data set variable?

You should show a bit more of what you are attempting for code. Since the macro language doesn't recognize "output" I strongly suspect you are mixing macro language and data step incorrectly.

If you want to go over a bunch of DATA SET variables named DX1, DX2 etc then you likely want something more like:

 

array vars DX1 - DX50;

do i= 1 to dim(vars);

   if compress(vars[i],'.') in ('DS123') then output;

end;

 

View solution in original post

4 REPLIES 4
SASAna
Quartz | Level 8

Sorry! error is  -   ERROR: Required operator not found in expression: %sysfunc(compress(DX&i ,'.')) in

 

Code - 

 

%Do i=1 %to 25;
%if %sysfunc(compress(DX&i ,'.')) in ('DS123') %then output; 

Tom
Super User Tom
Super User

@SASAna wrote:

Hello SAS users,

 

Need help with compressing the dots in the macro variables of DX1 to DX50. and i am getting the below error

 

code  -

 

%Do i=1 %to 50;

%if %sysfunc(compress(DX&i) ,'.')) in ( ' DS123')  %then output;

 

Error - 

 

ERROR: Format name '.' not found or the width and/or decimal specified for the format used are out of range.

 

Thanks,

Ana


You need to post more of the log, make sure to use the Insert Code button in the menu bar to get a pop-up window to paste the text so that the formatting is preserved.

Also explain what you think that code is doing.  It looks to me like the condition in your %IF statement can never be true.  You are testing for a value that includes single quote character, but the value of &I would never include single quotes and even if it did you asked COMPRESS() to removed the single quotes.  Perhaps you wanted to generate an actual IF statement instead?  Then the quotes are needed for the SAS compiler to tell the difference between a variable name like DX1 and the a constant string like 'DS123'.

 

ballardw
Super User

That's what you get when you try to do data processing in the macro language. That many macro variables is often a sign of a not well designed issue.

And the macro language treats literal characters a bit differently than the data step and quotes are often inappropriate.

 

You are "compressing" the literal value DX1 for instance. So there is no "space"  or "." to begin with.

Is DX&i a macro variable? or a data set variable?

You should show a bit more of what you are attempting for code. Since the macro language doesn't recognize "output" I strongly suspect you are mixing macro language and data step incorrectly.

If you want to go over a bunch of DATA SET variables named DX1, DX2 etc then you likely want something more like:

 

array vars DX1 - DX50;

do i= 1 to dim(vars);

   if compress(vars[i],'.') in ('DS123') then output;

end;

 

Reeza
Super User
Macro code with diagnosis codes make me suspect you should use arrays instead of macros. Is that an option here? It simplifies your code significantly.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 4 replies
  • 1695 views
  • 2 likes
  • 4 in conversation