Hi,
suppose I have the variable diff and 5 other variables (among many others) a,b,c,d,e.
Whenever the diff = '' I want also the other 5 variabels also be =''.
I did the following code:
data have;
set have;
array variables[5]
a b c d e;
if diff = '' then
do i = 1 to 5
variables[i]= '';
end;
drop i ;
run;
But get errors... I guess that the logic of my syntax isn't correct, although I tried to do some modifications of the code and still get errors. Could you please help me?
Thank you!
data have;
set have;
array variables[5] a b c d e;
if diff ='' then call missing(of variables[*]);
run;
I think I got it: I should have put the if statement inside the do statament:
data have;
set have;
array variables[5]
a b c d e;
do i = 1 to 5;
if diff ='' then variables[i] = '';
end;
drop i;
run;
But if there is a better way I will be very happy to learn!!!
CALL MISSING()
This code doesn't care if diff and variables are character or numeric.
if missing(diff) then call missing(of variables(*));
data have;
set have;
array variables[5] a b c d e;
if diff ='' then call missing(of variables[*]);
run;
While you have some valid suggestions here, your original problem was a missing semicolon:
1 to 5 ;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.