DATA Step, Macro, Functions and more

Calculate partial Area under the curve values (AUC's)

Reply
Occasional Contributor
Posts: 5

Calculate partial Area under the curve values (AUC's)

[ Edited ]

data have;
infile cards expandtabs truncover;
input ID  Time Concentration;
cards;
21 0 0
21 0.021 27.1
21 0.033 74.9
21 0.052 142
21 0.094 191
21 0.18 197
21 0.346 242
21 0.51 350
21 1.015 442
21 2.015 555
21 3.01 593
21 4.013 540
21 5.016 425
21 6.016 460
21 7.02 610
21 9 514
21 10.001 466
21 11.007 503
21 12.014 415
21 13.024 458
21 14.017 448
21 28.035 44.7
21 56.02 366
21 88.033 278
21 120.026 247
21 215.973 228
21 246.013 186
21 276.978 251
21 306.206 210
21 334.98 190
21 365.073 183
21 393.094 179
21 425.052 217
21 456.056 180
21 484.043 290
21 522.051 317
21 550.059 201
21 582.078 339
;
run;

 

I am trying calculate partial AUC's (30 and 60 days interval). I need an output as of the following.

want:

ID     Time     area

21      60        xxx    (AUC of first 60 days)

21      30.1      xxx    (AUC from day 1 to  30)

21      30.2       xxx    (AUC from day 31 to  60)

21       120      xxx     ( (AUC from day 61 to 120)

21       120.1      xxx     ( (AUC from day 61 to  90)

21       120.2     xxx     ( (AUC from day 91 to 120)

and so on...

 

xxx- refers some calculated value.

 

Any help to achieve this ouput in SAS??

 

Thanks in advance.

 

Respected Advisor
Posts: 4,173

Re: Calculate partial AUC's

Posted in reply to imabition_gmail_com

You want in your result calculations by days but you give us in your source data a Time variable.

 

How do the values of Time translate into days, i.e. for Time=582.078?

 

Occasional Contributor
Posts: 5

Re: Calculate partial AUC's

@Patrick: Time is given in days. So, Time=582 corresponds to 582 days.

Respected Advisor
Posts: 4,173

Re: Calculate partial AUC's

[ Edited ]
Posted in reply to imabition_gmail_com

It looks to me that you want to create a report using different grouping conditions for time. I don't really understand what these grouping conditions are, so here just throwing an approach how you coud create grouping variables for further processing, i.e using Proc Means or Proc SQL or a data step for your calculations of variable area.

data demo;
  set have;
  grouping30=floor(time/30);
  grouping60=floor(time/60);
run;
Occasional Contributor
Posts: 5

Re: Calculate partial AUC's

@Patrick: Actually I need to calculate the Area under the curve (Concentration Vs. Time) using trapezoidal rule.
Super User
Posts: 11,343

Re: Calculate partial Area under the curve values (AUC's)

Posted in reply to imabition_gmail_com

What rule do you want to use for interpolation on your days? Since day 60 does not appear in your data there is not a value for the concentration. Are you assuming a linear interpolation for the value of concentration?

SAS Super FREQ
Posts: 3,753

Re: Calculate partial Area under the curve values (AUC's)

Posted in reply to imabition_gmail_com

See the articles "The trapezoidal rule of integration" and "A statistical application of numerical integration: The area under an ROC curve".

 

A SAS/IML module is provided. If you don't have SAS/IML, then you can use the DIF function in the DATA step to compute the widths of the trapezoids.

Ask a Question
Discussion stats
  • 6 replies
  • 369 views
  • 0 likes
  • 4 in conversation