Hi everyone,
I'm interested in keeping only BR-based regimens (1L,2L,3L) and remove other regimens from the dataset. I'm not interested in distinct observations by patient ID but rather all LOTs for BR-based regimen. I'm not sure how to go about this. Any insight would be helpful.
Following is the data I have -
| ID | DRUG_REGIMEN | LOT | regimen |
| 1 | Bortezomib | 1L | Chemo monotherapy |
| 1 | 2L | ||
| 1 | 3L | ||
| 2 | Lenalidomide | 1L | Chemo monotherapy |
| 2 | 2L | ||
| 2 | 3L | ||
| 3 | Bendamustine + Rituximab | 1L | BR-based |
| 3 | 2L | ||
| 3 | 3L | ||
| 4 | Bendamustine + Rituximab | 1L | BR-based |
| 4 | 2L | ||
| 4 | 3L | ||
| 5 | Vincristine | 1L | Chemo monotherapy |
| 5 | Methotrexate | 2L | Chemo monotherapy |
| 5 | Methotrexate + Vincristine | 3L | Other chemotherapy |
| 5 | Cyclophosphamide + Doxorubicin + Rituximab + Vincristine | 1L | RCHOP/CHOP-based |
| 5 | 2L | ||
| 5 | 3L | ||
| 6 | Bendamustine + Rituximab | 1L | BR-based |
| 6 | 2L | ||
| 6 | 3L |
Data I want -
| ID | DRUG_REGIMEN | LOT | regimen |
| 3 | Bendamustine + Rituximab | 1L | BR-based |
| 3 | 2L | ||
| 3 | 3L | ||
| 4 | Bendamustine + Rituximab | 1L | BR-based |
| 4 | 2L | ||
| 4 | 3L | ||
| 6 | Bendamustine + Rituximab | 1L | BR-based |
| 6 | 2L | ||
| 6 | 3L |
In the absence of sample data in the form of a working DATA step, this code is untested, but straightforward:
data want;
merge have (where=(LOT='1L' and regimen='BR-based') in=include)
have;
by id;
if include=1;
run;
It assumes:
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.