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
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;
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;
@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'.
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;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.