BookmarkSubscribeRSS Feed
jcooper3
Calcite | Level 5

Hi all-

I have the following dataset:

patient ID    drug class  quarter 1 quarter2 quarter3...
1                    4               0              1            1

1                    3               1               0            0

1                    7               0              0             0

1                    1               0              0             0

The quarters continue over 36 quarters and 0/1 under the quarter columns indicate use of that drug during that quarter.

I'm trying to determine the best way possible to note medication additions? This is a very large dataset (n=~900,000 pts) and I'm applying a rule to the addition- the drug has to show up for a consecutive 2 quarters for the person to be considered a "user"

Do I need to re-structure the data?

Any help would be greatly appreciated- thanks much!

2 REPLIES 2
PGStats
Opal | Level 21

To get the list of first additions, you can use an array, this way:

data have;

input patientID    drugClass  quarter1-quarter6;

datalines;

1 4 0 1 1 0 1 1

1 3 1 0 0 1 1 0

1 7 0 0 0 0 1 0

1 1 0 0 0 0 0 0

;

data firstAdditions(keep=patientID drugClass addq);

set have;

array q{*} quarter:;

do addQ = 1 to dim(q)-1;

       if q{addQ} and q{addQ+1} then do;

            output;

            leave;

            end;

       end;

run;


proc print data=firstAdditions noobs; run;

PG

PG
Haikuo
Onyx | Level 15

Another way to identify is to convert them into strings:

data want;

set have;

array qtr quarter:;

if find(cats(of qtr(*)),'11');

run;

Haikuo

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!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 402 views
  • 1 like
  • 3 in conversation