10-23-2016 06:52 PM - edited 10-23-2016 06:52 PM
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 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?
10-23-2016 07:08 PM
I think I got it: I should have put the if statement inside the do statament:
data have; set have; array variables 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!!!
10-23-2016 10:34 PM
This code doesn't care if diff and variables are character or numeric.
if missing(diff) then call missing(of variables(*));
Need further help from the community? Please ask a new question.