BookmarkSubscribeRSS Feed
Soontobeprofess
Calcite | Level 5

I am a graduate student and I need to analyze area under the curve for the following data set (individual subject), can someone give me a simple code for it please. I will do this for every subject and after that I will run the ANOVAs pre and post, thank you very much. 

Min    Glucose 

-775
073
273
1278
28106
43110
58102
73101
8899
10388
11882
13382
14880
16379
17876
19374
20975
22474
24478
3 REPLIES 3
Ksharp
Super User
data have;
input Min    Glucose ;
cards;
-7	75
0	73
2	73
12	78
28	106
43	110
58	102
73	101
88	99
103	88
118	82
133	82
148	80
163	79
178	76
193	74
209	75
224	74
244	78
;

data temp;
 set have;
 delta=dif(min);
 high=mean(lag(Glucose),Glucose);
run;
proc sql noprint;
select sum(delta*high) into : auc from temp;
quit;


proc sgplot data=have;
series x=min y=glucose;
inset "AUC=&auc";
run;
Soontobeprofess
Calcite | Level 5

Dear community

 

 Thank you so much for your help. The code runs fine. I have two more questions:

 

The first, I forgot to ask, I need to calculate AUC from minute 0 to 240 only. 

 

The second one, in case on missing data (in rare cases, some of the glucose sensors didn't catch the  last hour of glucose readings), how can i modify the code to compensate for it? Thank you very much. 

 

P

Ksharp
Super User
For first question:
Add a filter condition .

data temp;
set have(where=(min between 0 and 240));
..........


For second question, you can impute the missing value with lag value . Like :
data temp;
set have(where=(min between 0 and 240));
retain new_glucose ;
if not missing(glucose ) then new_glucose =glucose ;
drop glucose ;
run;

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1226 views
  • 0 likes
  • 2 in conversation