BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

Dear,

 

I am using following code.

 

I got the output I need except  for one subject .

 

Assuming that the exstdtc is the last dose  given before aesdt. 

 

In my output I need to have the larger dose taken when two different doses taken  on same day. Please help in my code

 

one

id                               aesdt

1                              24SEP2014

 

ex

id                     exstdtc                   exdose

1                    2015-08-28                    3.5

1                    2015-08-28                     7

 

output needed

id         aesdt                    exdose

1        24SEP2014                 7

 

proc sql;
create table dose as
select a.*,b.exdose
from one as a left join ex as b
on a.usubjid=b.usubjid and a.AESDT-b.exstdtc >0
group by a.usubjid,a.aesdt
having a.Aesdt-b.exstdtc=min(a.Aesdt-b.exstdtc);
quit;

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

I dont see the variable usubjid in either of your datasets? 🙂

Astounding
PROC Star

What should happen if a dose was given on the same day as the adverse event?  (Use that date vs. ignore it?)

Ksharp
Super User
I would more like to use Data Step.



proc sql;
create table dose as
select usubjid,aesdt,max(exdose) as exdose
from
(
select a.*,b.exdose
from one as a left join ex as b
on a.usubjid=b.usubjid and a.AESDT-b.exstdtc >0
group by a.usubjid,a.aesdt
having a.Aesdt-b.exstdtc=min(a.Aesdt-b.exstdtc)
)
group by usubjid,aesdt;
quit;

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
  • 3 replies
  • 1017 views
  • 1 like
  • 4 in conversation