0

I'm pretty new to pure SAS coding and trying to understand what the second last line is doing in below code

data dataset_2 (drop=column1 column2);
 set dataset1;
  by column3 column4 column5 column6;
 retain column1 .;
 if first.column6 then
    column1=.;
 column2=1;
 if column6='Y' & abs(sum(column7,-column1))<10 then
 do;
    column2=0;
 end;
 column1 = column7;
 if column8 = '?' then  
 do;
    if column9<1000 or column3 in ('000000','111111','222222','33333','44444') then
    do;
       column8='n';

    end;
    else  
    do;
       column8='Y';
    end;
 end;
if column2;
run;

Basically, the if column2; portion?

Many thanks for the help! I understand the rest of the code

MPT
  • 25
  • 4
  • Does this answer your question? [IF-THEN vs IF in SAS](https://stackoverflow.com/questions/23718029/if-then-vs-if-in-sas) – Richard May 25 '20 at 11:22
  • Thanks for the suggestion @Richard , but my question is a bit different – MPT May 26 '20 at 03:38

1 Answers1

3

It's known as a "subsetting if"; if the condition is true, then continue past that point. In this case, given no further logic before the run; statement, it will only output records when column2 is true (non-zero/non-missing).

Chris J
  • 7,549
  • 2
  • 25
  • 25