BookmarkSubscribeRSS Feed
Pooja
Fluorite | Level 6

Hello All,

I have a data set which is as follows:

ID

psy_vst

rx

drug

days

disp_date

123

     .

1

12

90

15141

123

      1

.

12

30

15153

123

      1

.

12

30

15195

123

      1

.

12

30

15225

123

      1

.

3

2

15227

123

      1

.

12

30

15266

123

     .

1

1

60

15271

123

      1

.

7

30

15278

123

      1

.

7

30

15311

123

      1

.

7

30

15341

ID is the patient ID number, psy_vst =1 indicates that the event was a physician visit, rx=1 indicates that the event was a pharmacy visit, each drug is represented by a particular number so the same number under the drug column indicates the same drug,, a different number indicates a different drug, the days variable indicates the days supply for the particular drug and the disp_date indicates the day the drug was given. I want to delete (and create a new dataset of these deleted values) when there is a physician visit associated with the same drug days supply +30 days after the dispense date of the drug from the pharmacy. So in the above example for patient 123, rows 2,3,4 should be deleted from this dataset (and put into a new one) and rows 1, 5, 6, 7, 8, 9, 10 will remain in the dataset as the visits in rows 8, 9, 10 are not for the same drug that was dispensed in the pharmacy on date 15271.

Please could somebody help me write such a code?

Thanks a lot!

Pooja Desai

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

Discussion stats
  • 0 replies
  • 961 views
  • 0 likes
  • 1 in conversation