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
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.