Hi SAS team,
By taking the reference value "NO" as base for the field "Tx" we need to filter out specific set of values.
we need to check for specific value of "No" and we need to look for previous value which should be "Yes". For All these records if the Num field value is missing for any record then that set of "yes " along with "No" records should pull in the output. As shown in the below example.
data Have;
input sub week1$ tx$ seq num;
cards;
01 w0 no 1 .
01 w1 yes 1 1
01 w2 yes 2 1
01 w3 no 3 .
01 w4 yes 4 .
01 w5 no 5 .
01 w7 no 6 .
01 w8 yes 7 .
01 w9 yes 8 1
01 w10 no 9 .
01 w11 yes 10 1
;
run;
output Should be in this way;
sub | week1 | tx | seq | num |
1 | w4 | yes | 4 |
|
1 | w5 | no | 5 |
|
1 | w8 | yes | 7 |
|
1 | w9 | yes | 8 | 1 |
1 | w10 | no | 9 |
|
Regards,
Raju
Just to Clarify. If an observation has tx="No" and num=. you want this record outputted along with all previous observations where tx="Yes" up until tx "No"? 🙂
yes, addition to that for all those records if Num field value is missing for any record then that set of "yes" along with "No" record should pull in the output.
Hi All,
Did any got the solution for above query ?
Regards,
raju
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.