BookmarkSubscribeRSS Feed
imabition_gmail_com
Calcite | Level 5

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.

 

6 REPLIES 6
Patrick
Opal | Level 21

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?

 

imabition_gmail_com
Calcite | Level 5

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

Patrick
Opal | Level 21

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;
imabition_gmail_com
Calcite | Level 5
@Patrick: Actually I need to calculate the Area under the curve (Concentration Vs. Time) using trapezoidal rule.
ballardw
Super User

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?

Rick_SAS
SAS Super FREQ

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.

sas-innovate-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

Plus, pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 2040 views
  • 0 likes
  • 4 in conversation