I will appreciate if someone can explain what the following code is doing. I do not have a way to debug this.
Thanks in advance.
data bk_baddata2 (KEEP = loan_id newbaddata4 newbaddata6 newbaddata7);
array bad(*) baddata4 baddata6 baddata7;
array new(*) newbaddata4 newbaddata6 newbaddata7;
retain newbaddata4 newbaddata6 newbaddata7;
if first.loan_id then
newbaddata4 = .;
newbaddata6 = .;
newbaddata7 = .;
do i = 1 to 3;
if bad(i) NE . then new(i) = bad(i);
the code actually sets the value of the baddata columns equal to the newbaddata columns if the baddata does not have a null value. then the last record per loan_id is only written into the dataset bk_baddata2 along with the loan_id and newbaddata columns.
regarding the use of retain, i'm not quite sure but i think the retain part and the if first.loan_id part is redundant. no default values were set in the retain statement so the default value will be missing. i'm not sure if both are really needed.
by any chance do you know what the result table should look like?
hope this helps. if ever i explained something wrong please do correct it. thanks!
It all depends on your input data - if you only have one obs per LOAN_ID, the answer is yes, otherwise #1 and #3 is NO, #2 is NO (it executes 3 times per observations, given your DO criteria.
And, why would you be asking the questions (other than a homework/quiz assignment), if you actually don't have any data to work through the discovery process with your own SAS system, input data, combined with some PUTLOG _ALL_; commands?