BookmarkSubscribeRSS Feed
JKUW
Calcite | Level 5

Study ID

Drug1

Drug2

Drug3

00001

1

0

0

00001

0

0

1

 

Hello,

 

I just started using SAS again and I have yet to refresh my memory.

I'm currently investigating 3 drugs - patients are only supposed to be prescribed to only 1 drug.

However, some patients received more than 1 drug (as depicted in the table above) and I want to delete these specific individuals from the data.

Any codes to identify and delete these individuals? Any advice/help would be appreciated.

 

3 REPLIES 3
novinosrin
Tourmaline | Level 20
Hi, There's studyid but where is Patient/individual id? Please post a more comprehensive sample of what you have and want. Thank you
JKUW
Calcite | Level 5

Hi novinosrin,

 

Study_ID in this case would be the patient_id.

 

unison
Lapis Lazuli | Level 10

Maybe this:

data have;
	format studyid z5.;
	input studyid drug1-drug3;
	datalines;
00001 1 0 0
00001 0 0 1
00002 0 1 0
;
run;

data want;
	set have;
	by studyid;

	if first.studyid then
		rx_total=0;
	rx_total+sum(of drug:);

	if last.studyid and rx_total=1 then
		output;
	drop rx_total;
run;

assumes only one drug can be 1 for any given observation.

-unison

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 430 views
  • 0 likes
  • 3 in conversation