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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 288 views
  • 0 likes
  • 3 in conversation