Ok Thanks a lot
Hello
please see pfutzner et al. J diabetes science and technology. 2013 7(5) 1275 for coirdinates
thanks.
Joan Lee Parkes
Consensus Error Grid
/*产生样本数据*/
data have;
pi=constant('PI');
call streaminit(123);
do i=1 to 500;
x=40+30*ranuni(2); y=40+40*ranuni(2); output;
end;
/*--Add data all over--*/
do i=1 to 100;
x=550*ranuni(2); y=550*ranuni(2); output;
end;
/*--Add data in the middle fan--*/
do i=1 to 2000;
x=40+360*ranuni(2);
y=x+(x-50)*2*tan(pi/4 *ranuni(2) -pi/8);
y=ifn(y>550 or y<0, ., y);
output;
end;
keep x y;
run;
/*画图*/
/*--Generate grid and point data--*/
data Grid;
input id rfbg sbg;
cards;
11 50 0
11 50 30
11 90 80
11 330 230
11 550 450
12 0 50
12 30 50
12 230 330
12 440 550
21 90 0
21 260 130
21 550 250
22 0 60
22 30 60
22 280 550
31 250 0
31 250 40
31 410 110
31 550 160
32 0 80
32 25 80
32 35 90
32 125 550
41 0 200
41 35 200
41 50 550
;
run;
data label;
xl=320; yl=280; label='A'; output;
xl=280; yl=320; label='A'; output;
xl=370; yl=220; label='B'; output;
xl=220; yl=370; label='B'; output;
xl=400; yl=140; label='C'; output;
xl=140; yl=400; label='C'; output;
xl=420; yl=70; label='D'; output;
xl=70; yl=420; label='D';output;
xl=20; yl=430; label='E';output;
run;
/*--Add data points--*/
data Plot;
set grid have label;
run;
/*--Draw the grid--*/
ods html dpi=300;
ods graphics / reset antialiasmax=5700 ;
proc sgplot data=Plot noautolegend aspect=1;
lineparm x=0 y=0 slope=1/lineattrs=(pattern=dash color=gray);
series x=rfbg y=sbg / group=id lineattrs=(color=gray ) nomissinggroup;
scatter x=x y=y / markerattrs=(symbol=circlefilled size=2 color=black) transparency=0.5;
scatter x=xl y=yl / markerchar=label markercharattrs=(size=12);
xaxis values=(0 to 550 by 50) offsetmin=0 offsetmax=0 label='Reference Blood Glucose';
yaxis values=(0 to 550 by 50) offsetmin=0 offsetmax=0 label='Sensor Blood Glucose';
run;
To complete Consensus Error Grid to calculate percent in each area . I rescue to PROC GINSIDE. This PROC is awesome.
NOTE: unit is (mg/dL)
/*产生样本数据*/
data have;
pi=constant('PI');
call streaminit(123);
do i=1 to 500;
x=40+30*ranuni(2); y=40+40*ranuni(2); output;
end;
/*--Add data all over--*/
do i=1 to 100;
x=550*ranuni(2); y=550*ranuni(2); output;
end;
/*--Add data in the middle fan--*/
do i=1 to 2000;
x=40+360*ranuni(2);
y=x+(x-50)*2*tan(pi/4 *ranuni(2) -pi/8);
y=ifn(y>550 or y<0, ., y);
output;
end;
keep x y;
run;
/*画图*/
/*--Generate grid and point data--*/
data map;
input id $ x y;
cards;
B_L 50 0
B_L 50 30
B_L 90 80
B_L 330 230
B_L 550 450
B_L 550 250
B_L 260 130
B_L 90 0
C_L 90 0
C_L 260 130
C_L 550 250
C_L 550 160
C_L 410 110
C_L 250 40
C_L 250 0
D_L 250 0
D_L 250 40
D_L 410 110
D_L 550 160
D_L 550 0
A 50 0
A 50 30
A 90 80
A 330 230
A 550 450
A 550 550
A 440 550
A 230 330
A 30 50
A 0 50
A 0 0
B_U 0 50
B_U 30 50
B_U 230 330
B_U 440 550
B_U 280 550
B_U 30 60
B_U 0 60
C_U 0 60
C_U 30 60
C_U 280 550
C_U 125 550
C_U 35 90
C_U 25 80
C_U 0 80
D_U 0 80
D_U 25 80
D_U 35 90
D_U 125 550
D_U 50 550
D_U 35 200
D_U 0 200
E 0 200
E 35 200
E 50 550
E 0 550
;
run;
/*判断点在哪个区域*/
proc ginside data=have map=map out=id INCLUDEBORDER;
id id ;
run;
data id;
set id;
id=scan(id,1,'_');
run;
proc freq data=id ;
table id;
run;
data Grid;
input id2 rfbg sbg;
cards;
11 50 0
11 50 30
11 90 80
11 330 230
11 550 450
12 0 50
12 30 50
12 230 330
12 440 550
21 90 0
21 260 130
21 550 250
22 0 60
22 30 60
22 280 550
31 250 0
31 250 40
31 410 110
31 550 160
32 0 80
32 25 80
32 35 90
32 125 550
41 0 200
41 35 200
41 50 550
;
run;
data label;
xl=320; yl=280; label='A'; output;
xl=280; yl=320; label='A'; output;
xl=370; yl=220; label='B'; output;
xl=220; yl=370; label='B'; output;
xl=400; yl=140; label='C'; output;
xl=140; yl=400; label='C'; output;
xl=420; yl=70; label='D'; output;
xl=70; yl=420; label='D';output;
xl=20; yl=430; label='E';output;
run;
/*--Add data points--*/
data Plot;
set grid id label;
run;
/*--Attributes Map for zones--*/
data attrmap;
length id $1 value $1 markercolor $10;
id='A'; value='A'; markercolor='cx00afdf'; linecolor='cx00afdf'; output;
id='A'; value='B'; markercolor='cx00ef7f'; linecolor='cx00ef7f'; output;
id='A'; value='C'; markercolor='gray'; linecolor='gray'; output;
id='A'; value='D'; markercolor='pink'; linecolor='pink'; output;
id='A'; value='E'; markercolor='red'; linecolor='red'; output;
run;
/*--Draw the grid--*/
ods html dpi=300;
ods graphics / reset antialiasmax=5700 ;
proc sgplot data=Plot noautolegend aspect=1 dattrmap=attrmap;
lineparm x=0 y=0 slope=1/lineattrs=(pattern=dash color=gray );
series x=rfbg y=sbg / group=id2 lineattrs=(color=gray ) nomissinggroup;
scatter x=x y=y / markerattrs=(symbol=circlefilled size=2 ) group=id attrid=A;
scatter x=xl y=yl / markerchar=label markercharattrs=(size=12);
xaxis values=(0 to 550 by 50) offsetmin=0 offsetmax=0 label='Reference Blood Glucose';
yaxis values=(0 to 550 by 50) offsetmin=0 offsetmax=0 label='Sensor Blood Glucose';
run;
Dear Ksharp,
Thank you so much for providing this code!
I am just new to SAS and am wondering how I insert my own two input arrays of model value and reference value.
Thank you so much in advance!
Kind regards,
Rody
You could replace my HAVE dataset with yours . a.k.a replace the following code .
/*产生样本数据*/ data have; pi=constant('PI'); call streaminit(123); do i=1 to 500; x=40+30*ranuni(2); y=40+40*ranuni(2); output; end; /*--Add data all over--*/ do i=1 to 100; x=550*ranuni(2); y=550*ranuni(2); output; end; /*--Add data in the middle fan--*/ do i=1 to 2000; x=40+360*ranuni(2); y=x+(x-50)*2*tan(pi/4 *ranuni(2) -pi/8); y=ifn(y>550 or y<0, ., y); output; end; keep x y; run;
Or just type it by your hand. Like this :
data have; input x y; cards; 51.6 77.60 63.2 60.7 43.2 45.2 ; run;
Thanks a ton!
Here is Clark Error Grid Graph by using PROC GINSIDE .
NOTE: unit is (mg/dL)
/*产生样本数据*/
data have;
pi=constant('PI');
call streaminit(123);
do i=1 to 500;
x=40+30*ranuni(2); y=40+40*ranuni(2); output;
end;
/*--Add data all over--*/
do i=1 to 100;
x=400*ranuni(2); y=400*ranuni(2); output;
end;
/*--Add data in the middle fan--*/
do i=1 to 5000;
x=40+360*ranuni(2);
y=x+(x-50)*2*tan(pi/4 *ranuni(2) -pi/8);
y=ifn(y>400 or y<0, ., y);
output;
end;
x=70;y=84;output;
x=70;y=56;output;
keep x y;
run;
/*画图*/
/*--Generate grid and point data--*/
data map;
infile cards expandtabs;
input n id $ x y;
cards;
1 E_L 180 0
2 E_L 180 70
3 E_L 400 70
4 E_L 400 0
40 E_U 0 180
41 E_U 70 180
42 E_U 70 400
43 E_U 0 400
8 D_L 240 70
9 D_L 240 180
10 D_L 400 180
11 D_L 400 70
35 D_U 0 70
36 D_U 58.3 70
37 D_U 70 84
38 D_U 70 180
39 D_U 0 180
5 C_L 130 0
6 C_L 180 70
7 C_L 180 0
32 C_U 70 180
33 C_U 290 400
34 C_U 70 400
12 B_L 70 0
13 B_L 70 56
14 B_L 400 320
15 B_L 400 180
16 B_L 240 180
17 B_L 240 70
18 B_L 180 70
19 B_L 130 0
28 B_U 70 84
29 B_U 333 400
30 B_U 290 400
31 B_U 70 180
20 A 0 0
21 A 0 70
22 A 58.3 70
23 A 333 400
24 A 400 400
25 A 400 320
26 A 70 56
27 A 70 0
;
run;
data map;
set map;
if n in (23 29) then x=400/1.2 ;
if n in (22 36) then x=70/1.2 ;
drop n;
run;
/*判断点在哪个区域*/
proc ginside data=have map=map out=id INCLUDEBORDER;
id id ;
run;
data id;
set id;
id=scan(id,1,'_');
run;
proc freq data=id ;
table id/out=zone;
run;
%let A=0.00;
%let B=0.00;
%let C=0.00;
%let D=0.00;
%let E=0.00;
%let count_A=0;
%let count_B=0;
%let count_C=0;
%let count_D=0;
%let count_E=0;
data _null_;
set zone;
if not missing(id) then do;
call symputx(id,put(PERCENT,8.2));
call symputx(cats('count_',id),COUNT);
end;
run;
data Grid;
/*--Zone A--*/
id2=11; rfbg2=70; sbg2=0; output;
id2=11; rfbg2=70; sbg2=56; output;
id2=12; rfbg2=58.3;sbg2=70; output;
id2=12; rfbg2=0; sbg2=70; output;
id2=13; rfbg2=70; sbg2=84; output;
id2=13; rfbg2=70; sbg2=180; output;
id2=13; rfbg2=0; sbg2=180; output;
/*--Zone E - Y--*/
id2=3; rfbg2=70; sbg2=180; output;
id2=3; rfbg2=70; sbg2=400; output;
id2=3; rfbg2=0; sbg2=400; output;
/*--Zone E - X--*/
id2=4; rfbg2=180; sbg2=0; output;
id2=4; rfbg2=180; sbg2=70; output;
id2=4; rfbg2=400; sbg2=70; output;
/*--Zone D - X--*/
id2=5; rfbg2=240; sbg2=70; output;
id2=5; rfbg2=240; sbg2=180; output;
id2=5; rfbg2=400; sbg2=180; output;
/*--Zone C - Low--*/
id2=6; rfbg2=130; sbg2=0; output;
id2=6; rfbg2=180; sbg2=70; output;
/*--Zone C - High--*/
id2=7; rfbg2=70; sbg2=180; output;
id2=7; rfbg2=290; sbg2=400; output;
/*--Zone B - High--*/
id2=8; rfbg2=58.3; sbg2=70; output;
id2=8; rfbg2=333.3; sbg2=400; output;
/*--Zone B - Low--*/
id2=9; rfbg2=70; sbg2=56; output;
id2=9; rfbg2=400; sbg2=320; output;
run;
data label;
length label $ 40;
xl=20; yl=20; label='A'; output;
xl=20; yl=120; label='D'; output;
xl=20; yl=300; label='E'; output;
xl=100; yl=20; label='B'; output;
xl=160; yl=20; label='C'; output;
xl=100; yl=160; label='B'; output;
xl=320; yl=20; label="E(&count_E.,&E.%)"; output;
xl=320; yl=120; label="D(&count_D.,&D.%)"; output;
xl=320; yl=200; label="B(&count_B.,&B.%)" ; output;
xl=340; yl=340; label="A(&count_A.,&A.%)" ; output;
xl=120; yl=320; label="C(&count_C.,&C.%)" ; output;
run;
data plot;
set Grid id label;
run;
/*--Attributes Map for zones--*/
data attrmap;
length id $1 value $1 markercolor $10;
id='A'; value='A'; markercolor='cx00afdf'; linecolor='cx00afdf'; output;
id='A'; value='B'; markercolor='cx00ef7f'; linecolor='cx00ef7f'; output;
id='A'; value='C'; markercolor='gray'; linecolor='gray'; output;
id='A'; value='D'; markercolor='pink'; linecolor='pink'; output;
id='A'; value='E'; markercolor='red'; linecolor='red'; output;
run;
/*--Draw the grid--*/
ods graphics / reset antialiasmax=5700 ;
proc sgplot data=plot noautolegend aspect=1 dattrmap=attrmap;
scatter x=x y=y / attrid=A group=id markerattrs=(symbol=circlefilled size=3 ) ;
scatter x=xl y=yl / markerchar=label markercharattrs=(size=12) ;
series x=rfbg2 y=sbg2 / group=id2 lineattrs=(color=gray ) nomissinggroup;
xaxis values=(0 to 400 by 50) offsetmin=0 offsetmax=0 label='Reference Blood Glucose';
yaxis values=(0 to 400 by 50) offsetmin=0 offsetmax=0 label='Sensor Blood Glucose';
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.