I have the below code as a reference which i am using and i am almost there in getting my final graph but missing few things can someone help me with getting the labels in between and also within the bars as well.
The below is the sample code
%let name=bar4;
filename odsout 'C:\Users\ravindra.babu\OneDrive - OneWorkplace\Projs';
proc format; picture posval low-high='000,009'; run;
data my_data;
input ITEM $ 1-6 left right;
format amount posval.;
illusion='Group 1'; amount=-1*left; output;
illusion='Group 2'; amount=right; output;
datalines;
ITEM A 41 58
ITEM B 53 51
ITEM C 42 33
ITEM D 23 28
ITEM E 12 17
ITEM F 18 13
;
run;
data my_data; set my_data;
length htmlvar $300;
htmlvar=
'title='||quote(
'Item: '|| trim(left(item))||'0D'x||
'Group 1: '|| trim(left(left))||'0D'x||
'Group 2: '|| trim(left(right))
)||
' href="bar4_info.htm"';
run;
goptions device=png;
goptions noborder;
ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm"
(title="GChart Paired-Bar Chart")
style=htmlblue;
goptions gunit=pct htitle=6 ftitle="albany amt/bold" htext=4.25 ftext="albany amt/bold";
goptions ctext=gray33;
axis1 label=none;
axis2 label=none order=(-60 to 60 by 10) minor=none offset=(0,0) value=(h=3pct);
pattern1 v=solid color=cxbd0026;
pattern2 v=solid color=cx43a2ca;
legend1 label=none position=(bottom) cframe=white
shape=bar(3,3) cborder=white across=2;
title1 ls=1.5 "Paired-Bar Chart";
proc gchart data=my_data;
hbar item / discrete type=sum sumvar=amount nostats
subgroup=illusion
maxis=axis1 raxis=axis2
autoref clipref cref=graycc
legend=legend1 coutline=same
html=htmlvar
des="" name="&name";
run;
quit;
ODS HTML CLOSE;
ODS LISTING;
The below is the final example output that i am looking for, can i get some help on this please.
How about this one ?
proc format;
picture fmt
low-<0='000%' (mult=100)
0-high='000%' (mult=100)
;
value fmt_freq
1='Rarely'
2='Occasion'
3='Frequent'
4='Almost Constantly'
;
run;
data have;
infile cards truncover;
input visit freq low high n_one n_zero p_zero p_one n1 n2 p1 p2 p1_p p2_p zero text $40.;
label n1='N' n2='N' p1='Patients Without Symp(%)' p2='Patients Without Symp(%)';
format freq fmt_freq. low high fmt. p1 p2 percent8.0;
if high<=0 then do;high=high-0.1;low=low-0.1;end;
if low>=0 then do;high=high+0.1;low=low+0.1;end;
cards;
-0.5 1 -0.5 -0.4 -1.1 -0.1 0.1 1.1 81 47 0.88 0.79 -0.9 0.9 0 Before Treatment
-0.5 2 -0.4 -0.2
-0.5 3 -0.2 -0.12
-0.5 4 -0.12 0
-0.5 1 0.4 0.6
-0.5 2 0.3 0.4
-0.5 3 0.1 0.3
-0.5 4 0 0.1
1 1 -0.2 -0.1 -1.1 -0.1 0.1 1.1 86 37 0.9 0.68 -0.9 0.9 0 Week1
1 2 -0.1 0
1 1 0.2 0.4
1 2 0 0.2
2 3 -0.4 -0.3 -1.1 -0.1 0.1 1.1 89 48 0.93 0.73 -0.9 0.9 0 Week2
2 4 -0.3 0
2 3 0.3 0.4
2 4 0 0.3
3 2 -0.4 -0.1 -1.1 -0.1 0.1 1.1 92 49 0.96 0.9 -0.9 0.9 0 Week3
3 4 -0.1 0
3 2 0.1 0.2
3 4 0 0.1
4 1 -0.4 -0.3 -1.1 -0.1 0.1 1.1 81 41 0.94 0.9 -0.9 0.9 0 Week4
4 2 -0.3 -0.2
4 3 -0.2 -0.1
4 4 -0.1 0
4 1 0.3 0.4
4 2 0.2 0.3
4 3 0.1 0.2
4 4 0 0.1
5 2 -0.3 -0.2 -1.1 -0.1 0.1 1.1 82 37 0.93 0.74 -0.9 0.9 0 Week5
5 3 -0.2 0
5 2 0.2 0.6
5 3 0 0.2
6 2 -0.1 0 -1.1 -0.1 0.1 1.1 91 40 0.89 0.78 -0.9 0.9 0 Week6
6 3 0 0.4
;
proc sgplot data=have noborder;
title 'Tagrisson 80 mg Chemotherapy ';
styleattrs datacolors=( yellow orange navy verylightblue) ;
highlow y=visit low=n_one high=n_zero/type=bar fillattrs=(color=verydarkgreen)
nooutline transparency=0.8 name='n' legendlabel='Never';
highlow y=visit low=p_zero high=p_one/type=bar fillattrs=(color=verydarkgreen)
nooutline transparency=0.8;
highlow y=visit low=low high=high/type=bar group=freq nooutline name='a';
scatter y=visit x=p1_p/markerchar=p1 markercharattrs=(size=8) x2axis;
scatter y=visit x=p2_p/markerchar=p2 markercharattrs=(size=8) x2axis;
text y=visit x=zero text=text/strip contributeoffsets=none splitchar=' ' splitpolicy=splitalways textattrs=(size=8);
yaxistable n1/y=visit location=outside position=left valueattrs=(size=8 ) VALUEJUSTIFY=right VALUEHALIGN=right ;
yaxistable n2/y=visit location=outside position=right valueattrs=(size=8) VALUEJUSTIFY=left VALUEHALIGN=left;
xaxis values=(-1.1 to 1.1 by 0.2) display=(nolabel noline) valuesdisplay=(
'100%' '80%' '60%' '40%' '20%' '0%' '0%' '20%' '40%' '60%' '80%' '100%') offsetmin=0 offsetmax=0 ;
x2axis values=(-1 -0.7 0 0.7 1) display=(nolabel noline noticks) valuesdisplay=(
' ' 'Patients Without Symp(%)' ' ' 'Patients Without Symp(%)' ' ') offsetmin=0 offsetmax=0 ;
yaxis reverse display=none ;
keylegend 'n' 'a' /title='Frequency:';
run;
Have a look at the following examples:
For both of these links, check the example link to see the output, and the sas code link to see the SAS code generating the output.
Hope this helps
How about this one ?
proc format;
picture fmt
low-<0='000%' (mult=100)
0-high='000%' (mult=100)
;
value fmt_freq
1='Rarely'
2='Occasion'
3='Frequent'
4='Almost Constantly'
;
run;
data have;
infile cards truncover;
input visit freq low high n_one n_zero p_zero p_one n1 n2 p1 p2 p1_p p2_p zero text $40.;
label n1='N' n2='N' p1='Patients Without Symp(%)' p2='Patients Without Symp(%)';
format freq fmt_freq. low high fmt. p1 p2 percent8.0;
if high<=0 then do;high=high-0.1;low=low-0.1;end;
if low>=0 then do;high=high+0.1;low=low+0.1;end;
cards;
-0.5 1 -0.5 -0.4 -1.1 -0.1 0.1 1.1 81 47 0.88 0.79 -0.9 0.9 0 Before Treatment
-0.5 2 -0.4 -0.2
-0.5 3 -0.2 -0.12
-0.5 4 -0.12 0
-0.5 1 0.4 0.6
-0.5 2 0.3 0.4
-0.5 3 0.1 0.3
-0.5 4 0 0.1
1 1 -0.2 -0.1 -1.1 -0.1 0.1 1.1 86 37 0.9 0.68 -0.9 0.9 0 Week1
1 2 -0.1 0
1 1 0.2 0.4
1 2 0 0.2
2 3 -0.4 -0.3 -1.1 -0.1 0.1 1.1 89 48 0.93 0.73 -0.9 0.9 0 Week2
2 4 -0.3 0
2 3 0.3 0.4
2 4 0 0.3
3 2 -0.4 -0.1 -1.1 -0.1 0.1 1.1 92 49 0.96 0.9 -0.9 0.9 0 Week3
3 4 -0.1 0
3 2 0.1 0.2
3 4 0 0.1
4 1 -0.4 -0.3 -1.1 -0.1 0.1 1.1 81 41 0.94 0.9 -0.9 0.9 0 Week4
4 2 -0.3 -0.2
4 3 -0.2 -0.1
4 4 -0.1 0
4 1 0.3 0.4
4 2 0.2 0.3
4 3 0.1 0.2
4 4 0 0.1
5 2 -0.3 -0.2 -1.1 -0.1 0.1 1.1 82 37 0.93 0.74 -0.9 0.9 0 Week5
5 3 -0.2 0
5 2 0.2 0.6
5 3 0 0.2
6 2 -0.1 0 -1.1 -0.1 0.1 1.1 91 40 0.89 0.78 -0.9 0.9 0 Week6
6 3 0 0.4
;
proc sgplot data=have noborder;
title 'Tagrisson 80 mg Chemotherapy ';
styleattrs datacolors=( yellow orange navy verylightblue) ;
highlow y=visit low=n_one high=n_zero/type=bar fillattrs=(color=verydarkgreen)
nooutline transparency=0.8 name='n' legendlabel='Never';
highlow y=visit low=p_zero high=p_one/type=bar fillattrs=(color=verydarkgreen)
nooutline transparency=0.8;
highlow y=visit low=low high=high/type=bar group=freq nooutline name='a';
scatter y=visit x=p1_p/markerchar=p1 markercharattrs=(size=8) x2axis;
scatter y=visit x=p2_p/markerchar=p2 markercharattrs=(size=8) x2axis;
text y=visit x=zero text=text/strip contributeoffsets=none splitchar=' ' splitpolicy=splitalways textattrs=(size=8);
yaxistable n1/y=visit location=outside position=left valueattrs=(size=8 ) VALUEJUSTIFY=right VALUEHALIGN=right ;
yaxistable n2/y=visit location=outside position=right valueattrs=(size=8) VALUEJUSTIFY=left VALUEHALIGN=left;
xaxis values=(-1.1 to 1.1 by 0.2) display=(nolabel noline) valuesdisplay=(
'100%' '80%' '60%' '40%' '20%' '0%' '0%' '20%' '40%' '60%' '80%' '100%') offsetmin=0 offsetmax=0 ;
x2axis values=(-1 -0.7 0 0.7 1) display=(nolabel noline noticks) valuesdisplay=(
' ' 'Patients Without Symp(%)' ' ' 'Patients Without Symp(%)' ' ') offsetmin=0 offsetmax=0 ;
yaxis reverse display=none ;
keylegend 'n' 'a' /title='Frequency:';
run;
@Ksharp I had tried the above example that was given and applied to my data and i am not sure where i am missing can you please help me, the below is the code that i had written and the data i had used
proc sql;
create table ADQS4 as
select USUBJID,PARAM, PARAML,TYPEAE,VISLBL,TRTPN,AVALC,AVAL, strip(put(AVAL,8.)) as AVAL_c from ANA.ADQS4
where pepfl="Y" and RANDFL='Y' /*and PARAML='Vomiting (10)'*/ AND TYPEAE NE 'Composite' AND AVISITN NOT IN(1301,1401);
quit;
/*with vomiting*/
proc sort data=ADQS4 out=ADQS4_vom;
by VISLBL TRTPN;
where paraml='Vomiting (10)';
run;
proc freq data=ADQS4_vom;
by VISLBL;
tables AVAL_c*TRTPN/out=ADQS4_out;
run;
proc sort data=ADQS4_out;
by VISLBL aval_c TRTPN;
run;
proc transpose data=ADQS4_out out=ADQS4_out_trans(drop= _label_);
by VISLBL aval_c TRTPN;
var COUNT PERCENT;
run;
/*subsetting the trt*/
data trt1(rename=(col1=trt1)) trt2(rename=(col1=trt2));
set ADQS4_out_trans;
if TRTPN=1 then output trt1;
if TRTPN=2 then output trt2;
run;
/*subsetting the trt to get count and percent*/
proc sort data=trt1;
by VISLBL aval_c;
run;
proc transpose data=trt1 out=trt1_trans(drop=_name_ );
by VISLBL aval_c ;
var trt1;
run;
data trt1_trans1;
set trt1_trans;
if aval_c = . then delete;
rename COUNT=n1
percent=p1;
run;
/*trt2*/
proc sort data=trt2;
by VISLBL aval_c;
run;
proc transpose data=trt2 out=trt2_trans(drop=_name_ );
by VISLBL aval_c ;
var trt2;
run;
data trt2_trans1;
set trt2_trans;
if aval_c = . then delete;
rename COUNT=n2
percent=p2;
run;
proc sort data=trt1_trans1;
by VISLBL aval_c ;
run;
proc sort data=trt2_trans1;
by VISLBL aval_c ;
run;
data trt1_merge;
length aval $20.;
merge trt1_trans1 trt2_trans1;
by VISLBL aval_c ;
if aval_c='0' then aval='Not at all';
if aval_c='1' then aval='Rarely';
if aval_c='2' then aval='Occasionaly';
if aval_c='3' then aval='Frequently';
if aval_c='4' then aval='Almost Constantly';
run;
/*without vomiting*/
proc sort data=ADQS4 out=ADQS4_vom_tot;
by VISLBL;
run;
proc means data=ADQS4_vom_tot noprint;
class VISLBL AVAL_c/groupinternal;
var AVAL;
output out=class_summary;
run;
proc summary data=ADQS4_vom_tot();
class VISLBL TRTPN;
var AVAL;
output out=stats max=AVAL_max min=aval_min;
run;
proc freq data=ADQS4_vom_tot;
by VISLBL;
tables AVAL_c*TRTPN/out=ADQS4_out_tot;
run;
proc sort data=ADQS4_out_tot;
by VISLBL aval_c TRTPN;
run;
proc transpose data=ADQS4_out_tot out=ADQS4_out_trans_tot(drop= _label_);
by VISLBL aval_c TRTPN;
var COUNT PERCENT;
run;
/*subsetting the trt*/
data trt1_tot(rename=(col1=trt1)) trt2_tot(rename=(col1=trt2));
set ADQS4_out_trans_tot;
if TRTPN=1 then output trt1_tot;
if TRTPN=2 then output trt2_tot;
run;
/*subsetting the trt to get count and percent*/
proc sort data=trt1_tot;
by VISLBL aval_c;
run;
proc transpose data=trt1_tot out=trt1_trans_tot(drop=_name_ );
by VISLBL aval_c ;
var trt1;
run;
data trt1_trans1_tot;
set trt1_trans_tot;
if aval_c = . then delete;
rename COUNT=n_zero
percent=p_zero;
run;
/*trt2*/
proc sort data=trt2_tot;
by VISLBL aval_c;
run;
proc transpose data=trt2_tot out=trt2_trans_tot(drop=_name_ );
by VISLBL aval_c ;
var trt2;
run;
data trt2_trans1_tot;
set trt2_trans_tot;
if aval_c = . then delete;
rename COUNT=n_one
percent=p_one;
run;
proc sort data=trt1_trans1_tot;
by VISLBL aval_c ;
run;
proc sort data=trt2_trans1_tot;
by VISLBL aval_c ;
run;
data trt2_merge;
length aval $20.;
merge trt1_trans1_tot trt2_trans1_tot;
by VISLBL aval_c ;
if aval_c='0' then aval='Not at all';
if aval_c='1' then aval='Rarely';
if aval_c='2' then aval='Occasionaly';
if aval_c='3' then aval='Frequently';
if aval_c='4' then aval='Almost Constantly';
run;
*********************************************;
proc sort data=trt2_merge;
by VISLBL aval ;
run;
proc sort data=trt1_merge;
by VISLBL aval ;
run;
data final(drop=aval_c);
merge trt1_merge trt2_merge;
by VISLBL aval ;
run;
/*calculating min and max percentage*/
proc sql;
create table final_tot as
select *, sum(n_zero) as sum_ea, min(n_zero) as min, max(n_zero) as max
from final
group by VISLBL,aval
;
proc sort data = final_tot out = final_tot1 nodupkey;
by VISLBL sum_ea;
run;
proc sql;
create table final_tot1 as
select *, sum_ea / sum(sum_ea) * 100 as sum_percent,
min / sum(sum_ea) * 100 as low,
max / sum(sum_ea) * 100 as high
from final_tot
group by aval;
quit;
data final_g;
set final_tot1;
p1_p=-0.9;
p2_p=0.9;
zero=0;
if high<=0 then do;high=high-0.1;low=low-0.1;end;
if low>=0 then do;high=high+0.1;low=low+0.1;end;
label n1='N' n2='N' p1='Patients Without Symp(%)' p2='Patients Without Symp(%)';
if vislbl='Baseline' then visit=-0.5;
if vislbl='Cycle 2' then visit=1;
if vislbl='Cycle 3' then visit=2;
if vislbl='Cycle 4' then visit=3;
if vislbl='Cycle 5' then visit=4;
if vislbl='Cycle 6' then visit=5;
if vislbl='Cycle 7' then visit=6;
if vislbl='Cycle 8' then visit=7;
if vislbl='Cycle 9' then visit=8;
if vislbl='Cycle 10' then visit=9;
if vislbl='Cycle 11' then visit=10;
if vislbl='Cycle 12' then visit=11;
if vislbl='Cycle 13' then visit=12;
if vislbl='Cycle 14' then visit=13;
if vislbl='Cycle 15' then visit=14;
if vislbl='Cycle 16' then visit=15;
;
rename aval =freq
VISLBL=text;
run;
proc sort data=final_g;
by text freq;
run;
/*generaing graph*/
proc sgplot data=final_g noborder;
title 'Xenutuzumab with E+E Placebo with E+E ';
styleattrs datacolors=( yellow orange navy verylightblue) ;
highlow y=visit low=n_one high=n_zero/type=bar fillattrs=(color=verydarkgreen)
nooutline transparency=0.8 name='n' legendlabel='Never';
highlow y=visit low=p_zero high=p_one/type=bar fillattrs=(color=verydarkgreen)
nooutline transparency=0.8;
highlow y=visit low=low high=high/type=bar group=freq nooutline name='a';
scatter y=visit x=p1_p/markerchar=p1 markercharattrs=(size=8) x2axis;
scatter y=visit x=p2_p/markerchar=p2 markercharattrs=(size=8) x2axis;
text y=visit x=zero text=text/strip contributeoffsets=none splitchar=' ' splitpolicy=splitalways textattrs=(size=8);
yaxistable n1/y=visit location=outside position=left valueattrs=(size=8 ) VALUEJUSTIFY=right VALUEHALIGN=right ;
yaxistable n2/y=visit location=outside position=right valueattrs=(size=8) VALUEJUSTIFY=left VALUEHALIGN=left;
xaxis values=(-1.1 to 1.1 by 0.2) display=(nolabel noline) valuesdisplay=(
'100%' '80%' '60%' '40%' '20%' '0%' '0%' '20%' '40%' '60%' '80%' '100%') offsetmin=0 offsetmax=0 ;
x2axis values=(-1 -0.7 0 0.7 1) display=(nolabel noline noticks) valuesdisplay=(
' ' 'Patients Without Symp(%)' ' ' 'Patients Without Symp(%)' ' ') offsetmin=0 offsetmax=0 ;
yaxis reverse display=none ;
keylegend 'n' 'a' /title='Frequency:';
run;
the below is the data
USUBJID PARAML VISLBL TRTPN AVALC AVAL AVAL_c
1280-0022-1036002001 Difficulty Swallowing (02) Baseline 2 NONE 0 0
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 2 2 NONE 0 0
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 3 2 NONE 0 0
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 4 2 NONE 0 0
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 5 2 . .
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 6 2 NONE 0 0
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 7 2 . .
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 8 2 NONE 0 0
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 9 2 NONE 0 0
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 10 2 NONE 0 0
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 11 2 NONE 0 0
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 12 2 NONE 0 0
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Baseline 2 NONE 0 0
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 2 2 MILD 1 1
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 3 2 NONE 0 0
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 4 2 NONE 0 0
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 5 2 . .
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 6 2 NONE 0 0
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 7 2 . .
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 8 2 MILD 1 1
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 9 2 NONE 0 0
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 10 2 NONE 0 0
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 11 2 NONE 0 0
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 12 2 NONE 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Baseline 2 NONE 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 2 2 MILD 1 1
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 3 2 NONE 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 4 2 NONE 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 5 2 . .
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 6 2 MILD 1 1
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 7 2 . .
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 8 2 MODERTATE 2 2
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 9 2 MILD 1 1
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 10 2 NONE 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 11 2 NONE 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 12 2 MILD 1 1
1280-0022-1036002001 Decreased Appetite at Worst (08) Baseline 2 NOT AT ALL 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 2 2 NOT AT ALL 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 3 2 NOT AT ALL 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 4 2 NOT AT ALL 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 5 2 . .
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 6 2 A LITTLE BIT 1 1
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 7 2 . .
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 8 2 A LITTLE BIT 1 1
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 9 2 NOT AT ALL 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 10 2 NOT AT ALL 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 11 2 . .
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 12 2 NOT AT ALL 0 0
1280-0022-1036002001 Vomiting (10) Baseline 2 NEVER 0 0
1280-0022-1036002001 Vomiting (10) Cycle 2 2 NEVER 0 0
1280-0022-1036002001 Vomiting (10) Cycle 3 2 NEVER 0 0
1280-0022-1036002001 Vomiting (10) Cycle 4 2 NEVER 0 0
1280-0022-1036002001 Vomiting (10) Cycle 5 2 . .
1280-0022-1036002001 Vomiting (10) Cycle 6 2 NEVER 0 0
1280-0022-1036002001 Vomiting (10) Cycle 7 2 . .
1280-0022-1036002001 Vomiting (10) Cycle 8 2 RARELY 1 1
1280-0022-1036002001 Vomiting (10) Cycle 9 2 NEVER 0 0
1280-0022-1036002001 Vomiting (10) Cycle 10 2 NEVER 0 0
1280-0022-1036002001 Vomiting (10) Cycle 11 2 NEVER 0 0
1280-0022-1036002001 Vomiting (10) Cycle 12 2 NEVER 0 0
1280-0022-1036002001 Vomiting (10) Baseline 2 NONE 0 0
1280-0022-1036002001 Vomiting (10) Cycle 2 2 NONE 0 0
1280-0022-1036002001 Vomiting (10) Cycle 3 2 NONE 0 0
1280-0022-1036002001 Vomiting (10) Cycle 4 2 NONE 0 0
1280-0022-1036002001 Vomiting (10) Cycle 5 2 . .
1280-0022-1036002001 Vomiting (10) Cycle 6 2 NONE 0 0
1280-0022-1036002001 Vomiting (10) Cycle 7 2 . .
1280-0022-1036002001 Vomiting (10) Cycle 8 2 MILD 1 1
1280-0022-1036002001 Vomiting (10) Cycle 9 2 NONE 0 0
1280-0022-1036002001 Vomiting (10) Cycle 10 2 NONE 0 0
1280-0022-1036002001 Vomiting (10) Cycle 11 2 . .
1280-0022-1036002001 Vomiting (10) Cycle 12 2 . .
1280-0022-1036002001 Heartburn (11) Baseline 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Cycle 2 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Cycle 3 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Cycle 4 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Cycle 5 2 . .
1280-0022-1036002001 Heartburn (11) Cycle 6 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Cycle 7 2 . .
1280-0022-1036002001 Heartburn (11) Cycle 8 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Cycle 9 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Cycle 10 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Cycle 11 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Cycle 12 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Baseline 2 NONE 0 0
1280-0022-1036002001 Heartburn (11) Cycle 2 2 NONE 0 0
1280-0022-1036002001 Heartburn (11) Cycle 3 2 NONE 0 0
1280-0022-1036002001 Heartburn (11) Cycle 4 2 NONE 0 0
1280-0022-1036002001 Heartburn (11) Cycle 5 2 . .
1280-0022-1036002001 Heartburn (11) Cycle 6 2 NONE 0 0
1280-0022-1036002001 Heartburn (11) Cycle 7 2 . .
1280-0022-1036002001 Heartburn (11) Cycle 8 2 NONE 0 0
1280-0022-1036002001 Heartburn (11) Cycle 9 2 NONE 0 0
1280-0022-1036002001 Heartburn (11) Cycle 10 2 NONE 0 0
1280-0022-1036002001 Heartburn (11) Cycle 11 2 . .
1280-0022-1036002001 Heartburn (11) Cycle 12 2 . .
1280-0022-1036002001 Diarrhoea (16) Baseline 2 NEVER 0 0
1280-0022-1036002001 Diarrhoea (16) Cycle 2 2 OCCASIONALLY 2 2
1280-0022-1036002001 Diarrhoea (16) Cycle 3 2 NEVER 0 0
1280-0022-1036002001 Diarrhoea (16) Cycle 4 2 NEVER 0 0
1280-0022-1036002001 Diarrhoea (16) Cycle 5 2 . .
1280-0022-1036002001 Diarrhoea (16) Cycle 6 2 RARELY 1 1
1280-0022-1036002001 Diarrhoea (16) Cycle 7 2 . .
1280-0022-1036002001 Diarrhoea (16) Cycle 8 2 FREQUENTLY 3 3
1280-0022-1036002001 Diarrhoea (16) Cycle 9 2 NEVER 0 0
1280-0022-1036002001 Diarrhoea (16) Cycle 10 2 NEVER 0 0
1280-0022-1036002001 Diarrhoea (16) Cycle 11 2 NEVER 0 0
1280-0022-1036002001 Diarrhoea (16) Cycle 12 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Baseline 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 2 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 3 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 4 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 5 2 . .
1280-0022-1036002001 Pain in Abdomen (17) Cycle 6 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 7 2 . .
1280-0022-1036002001 Pain in Abdomen (17) Cycle 8 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 9 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 10 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 11 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 12 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Baseline 2 NONE 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 2 2 NONE 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 3 2 NONE 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 4 2 NONE 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 5 2 . .
1280-0022-1036002001 Pain in Abdomen (17) Cycle 6 2 NONE 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 7 2 . .
1280-0022-1036002001 Pain in Abdomen (17) Cycle 8 2 NONE 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 9 2 NONE 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 10 2 NONE 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 11 2 NONE 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 12 2 . .
1280-0022-1036002001 Pain in Abdomen (17) Baseline 2 NOT AT ALL 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 2 2 NOT AT ALL 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 3 2 NOT AT ALL 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 4 2 NOT AT ALL 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 5 2 . .
1280-0022-1036002001 Pain in Abdomen (17) Cycle 6 2 NOT AT ALL 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 7 2 . .
1280-0022-1036002001 Pain in Abdomen (17) Cycle 8 2 NOT AT ALL 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 9 2 NOT AT ALL 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 10 2 NOT AT ALL 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 11 2 . .
1280-0022-1036002001 Pain in Abdomen (17) Cycle 12 2 . .
1280-0022-1036002001 Rash (23) Baseline 2 N 0 0
1280-0022-1036002001 Rash (23) Cycle 2 2 N 0 0
1280-0022-1036002001 Rash (23) Cycle 3 2 N 0 0
1280-0022-1036002001 Rash (23) Cycle 4 2 N 0 0
1280-0022-1036002001 Rash (23) Cycle 5 2 . .
1280-0022-1036002001 Rash (23) Cycle 6 2 N 0 0
1280-0022-1036002001 Rash (23) Cycle 7 2 . .
1280-0022-1036002001 Rash (23) Cycle 8 2 N 0 0
1280-0022-1036002001 Rash (23) Cycle 9 2 N 0 0
1280-0022-1036002001 Rash (23) Cycle 10 2 N 0 0
1280-0022-1036002001 Rash (23) Cycle 11 2 N 0 0
1280-0022-1036002001 Rash (23) Cycle 12 2 N 0 0
can you please guide me where i am missing.
I don't know how to distinguish LEFT or RIGHT value by you .
If you could organize your data very well as HAVE dataset of mine . you would get the result.
Here is an example. I have no time to finish all these .
data have;
infile cards expandtabs truncover;
input (USUBJID PARAML VISLBL TRTPN AVALC AVAL AVAL_c) (& $40.);
freq=input(scan(PARAML,-1,'() '),best.);
if vislbl=:'Baseline' then visit=-0.5;
if vislbl=:'Cycle 2' then visit=1;
if vislbl=:'Cycle 3' then visit=2;
if vislbl=:'Cycle 4' then visit=3;
if vislbl=:'Cycle 5' then visit=4;
if vislbl=:'Cycle 6' then visit=5;
if vislbl=:'Cycle 7' then visit=6;
if vislbl=:'Cycle 8' then visit=7;
if vislbl=:'Cycle 9' then visit=8;
if vislbl=:'Cycle 10' then visit=9;
if vislbl=:'Cycle 11' then visit=10;
if vislbl=:'Cycle 12' then visit=11;
if vislbl=:'Cycle 13' then visit=12;
if vislbl=:'Cycle 14' then visit=13;
if vislbl=:'Cycle 15' then visit=14;
if vislbl=:'Cycle 16' then visit=15;
keep visit freq;
cards;
1280-0022-1036002001 Difficulty Swallowing (02) Baseline 2 NONE 0 0
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 2 2 NONE 0 0
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 3 2 NONE 0 0
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 4 2 NONE 0 0
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 5 2 . .
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 6 2 NONE 0 0
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 7 2 . .
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 8 2 NONE 0 0
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 9 2 NONE 0 0
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 10 2 NONE 0 0
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 11 2 NONE 0 0
1280-0022-1036002001 Difficulty Swallowing (02) Cycle 12 2 NONE 0 0
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Baseline 2 NONE 0 0
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 2 2 MILD 1 1
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 3 2 NONE 0 0
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 4 2 NONE 0 0
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 5 2 . .
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 6 2 NONE 0 0
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 7 2 . .
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 8 2 MILD 1 1
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 9 2 NONE 0 0
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 10 2 NONE 0 0
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 11 2 NONE 0 0
1280-0022-1036002001 Skin Cracking Corners Mouth (04) Cycle 12 2 NONE 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Baseline 2 NONE 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 2 2 MILD 1 1
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 3 2 NONE 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 4 2 NONE 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 5 2 . .
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 6 2 MILD 1 1
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 7 2 . .
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 8 2 MODERTATE 2 2
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 9 2 MILD 1 1
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 10 2 NONE 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 11 2 NONE 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 12 2 MILD 1 1
1280-0022-1036002001 Decreased Appetite at Worst (08) Baseline 2 NOT AT ALL 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 2 2 NOT AT ALL 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 3 2 NOT AT ALL 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 4 2 NOT AT ALL 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 5 2 . .
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 6 2 A LITTLE BIT 1 1
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 7 2 . .
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 8 2 A LITTLE BIT 1 1
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 9 2 NOT AT ALL 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 10 2 NOT AT ALL 0 0
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 11 2 . .
1280-0022-1036002001 Decreased Appetite at Worst (08) Cycle 12 2 NOT AT ALL 0 0
1280-0022-1036002001 Vomiting (10) Baseline 2 NEVER 0 0
1280-0022-1036002001 Vomiting (10) Cycle 2 2 NEVER 0 0
1280-0022-1036002001 Vomiting (10) Cycle 3 2 NEVER 0 0
1280-0022-1036002001 Vomiting (10) Cycle 4 2 NEVER 0 0
1280-0022-1036002001 Vomiting (10) Cycle 5 2 . .
1280-0022-1036002001 Vomiting (10) Cycle 6 2 NEVER 0 0
1280-0022-1036002001 Vomiting (10) Cycle 7 2 . .
1280-0022-1036002001 Vomiting (10) Cycle 8 2 RARELY 1 1
1280-0022-1036002001 Vomiting (10) Cycle 9 2 NEVER 0 0
1280-0022-1036002001 Vomiting (10) Cycle 10 2 NEVER 0 0
1280-0022-1036002001 Vomiting (10) Cycle 11 2 NEVER 0 0
1280-0022-1036002001 Vomiting (10) Cycle 12 2 NEVER 0 0
1280-0022-1036002001 Vomiting (10) Baseline 2 NONE 0 0
1280-0022-1036002001 Vomiting (10) Cycle 2 2 NONE 0 0
1280-0022-1036002001 Vomiting (10) Cycle 3 2 NONE 0 0
1280-0022-1036002001 Vomiting (10) Cycle 4 2 NONE 0 0
1280-0022-1036002001 Vomiting (10) Cycle 5 2 . .
1280-0022-1036002001 Vomiting (10) Cycle 6 2 NONE 0 0
1280-0022-1036002001 Vomiting (10) Cycle 7 2 . .
1280-0022-1036002001 Vomiting (10) Cycle 8 2 MILD 1 1
1280-0022-1036002001 Vomiting (10) Cycle 9 2 NONE 0 0
1280-0022-1036002001 Vomiting (10) Cycle 10 2 NONE 0 0
1280-0022-1036002001 Vomiting (10) Cycle 11 2 . .
1280-0022-1036002001 Vomiting (10) Cycle 12 2 . .
1280-0022-1036002001 Heartburn (11) Baseline 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Cycle 2 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Cycle 3 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Cycle 4 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Cycle 5 2 . .
1280-0022-1036002001 Heartburn (11) Cycle 6 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Cycle 7 2 . .
1280-0022-1036002001 Heartburn (11) Cycle 8 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Cycle 9 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Cycle 10 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Cycle 11 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Cycle 12 2 NEVER 0 0
1280-0022-1036002001 Heartburn (11) Baseline 2 NONE 0 0
1280-0022-1036002001 Heartburn (11) Cycle 2 2 NONE 0 0
1280-0022-1036002001 Heartburn (11) Cycle 3 2 NONE 0 0
1280-0022-1036002001 Heartburn (11) Cycle 4 2 NONE 0 0
1280-0022-1036002001 Heartburn (11) Cycle 5 2 . .
1280-0022-1036002001 Heartburn (11) Cycle 6 2 NONE 0 0
1280-0022-1036002001 Heartburn (11) Cycle 7 2 . .
1280-0022-1036002001 Heartburn (11) Cycle 8 2 NONE 0 0
1280-0022-1036002001 Heartburn (11) Cycle 9 2 NONE 0 0
1280-0022-1036002001 Heartburn (11) Cycle 10 2 NONE 0 0
1280-0022-1036002001 Heartburn (11) Cycle 11 2 . .
1280-0022-1036002001 Heartburn (11) Cycle 12 2 . .
1280-0022-1036002001 Diarrhoea (16) Baseline 2 NEVER 0 0
1280-0022-1036002001 Diarrhoea (16) Cycle 2 2 OCCASIONALLY 2 2
1280-0022-1036002001 Diarrhoea (16) Cycle 3 2 NEVER 0 0
1280-0022-1036002001 Diarrhoea (16) Cycle 4 2 NEVER 0 0
1280-0022-1036002001 Diarrhoea (16) Cycle 5 2 . .
1280-0022-1036002001 Diarrhoea (16) Cycle 6 2 RARELY 1 1
1280-0022-1036002001 Diarrhoea (16) Cycle 7 2 . .
1280-0022-1036002001 Diarrhoea (16) Cycle 8 2 FREQUENTLY 3 3
1280-0022-1036002001 Diarrhoea (16) Cycle 9 2 NEVER 0 0
1280-0022-1036002001 Diarrhoea (16) Cycle 10 2 NEVER 0 0
1280-0022-1036002001 Diarrhoea (16) Cycle 11 2 NEVER 0 0
1280-0022-1036002001 Diarrhoea (16) Cycle 12 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Baseline 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 2 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 3 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 4 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 5 2 . .
1280-0022-1036002001 Pain in Abdomen (17) Cycle 6 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 7 2 . .
1280-0022-1036002001 Pain in Abdomen (17) Cycle 8 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 9 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 10 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 11 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 12 2 NEVER 0 0
1280-0022-1036002001 Pain in Abdomen (17) Baseline 2 NONE 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 2 2 NONE 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 3 2 NONE 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 4 2 NONE 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 5 2 . .
1280-0022-1036002001 Pain in Abdomen (17) Cycle 6 2 NONE 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 7 2 . .
1280-0022-1036002001 Pain in Abdomen (17) Cycle 8 2 NONE 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 9 2 NONE 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 10 2 NONE 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 11 2 NONE 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 12 2 . .
1280-0022-1036002001 Pain in Abdomen (17) Baseline 2 NOT AT ALL 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 2 2 NOT AT ALL 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 3 2 NOT AT ALL 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 4 2 NOT AT ALL 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 5 2 . .
1280-0022-1036002001 Pain in Abdomen (17) Cycle 6 2 NOT AT ALL 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 7 2 . .
1280-0022-1036002001 Pain in Abdomen (17) Cycle 8 2 NOT AT ALL 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 9 2 NOT AT ALL 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 10 2 NOT AT ALL 0 0
1280-0022-1036002001 Pain in Abdomen (17) Cycle 11 2 . .
1280-0022-1036002001 Pain in Abdomen (17) Cycle 12 2 . .
1280-0022-1036002001 Rash (23) Baseline 2 N 0 0
1280-0022-1036002001 Rash (23) Cycle 2 2 N 0 0
1280-0022-1036002001 Rash (23) Cycle 3 2 N 0 0
1280-0022-1036002001 Rash (23) Cycle 4 2 N 0 0
1280-0022-1036002001 Rash (23) Cycle 5 2 . .
1280-0022-1036002001 Rash (23) Cycle 6 2 N 0 0
1280-0022-1036002001 Rash (23) Cycle 7 2 . .
1280-0022-1036002001 Rash (23) Cycle 8 2 N 0 0
1280-0022-1036002001 Rash (23) Cycle 9 2 N 0 0
1280-0022-1036002001 Rash (23) Cycle 10 2 N 0 0
1280-0022-1036002001 Rash (23) Cycle 11 2 N 0 0
1280-0022-1036002001 Rash (23) Cycle 12 2 N 0 0
;
proc sort data=have;by visit freq;run;
data have;
set have;
by visit freq;
left=first.freq ;
run;
proc sql;
create table have2 as
select visit,left,freq,
count(*)/(select count(*) from have where left=a.left) as pct
from have as a
group by visit,left,freq ;
quit;
data have3;
set have2;
by visit left;
if first.left then cum=0;
cum+pct;
run;
data have4;
set have3;
if left then cum=-cum;
run;
data have5;
set have4;
by visit left;
lag_cum=lag(cum);
if first.left then lag_cum=0;
drop pct;
run;
data have6;
set have5;
if left then do;high=lag_cum;low=cum;end;
else do;high=cum;low=lag_cum;end;
drop cum lag_cum;
run;
proc format;
value fmt_freq
2='Rarely'
4='Occasion'
8='Frequent'
10='Almost Constantly'
11='Almost 1'
16='Almost 2'
17='Almost 3'
23='Almost 4'
;
run;
data have7;
set have6;
by visit;
if first.visit then do;
n_one=-1.1;
n_zero=-0.1;
p_zero=0.1;
p_one=1.1;
p1_p=-0.9;
p2_p=0.9;
zero=0;
select(visit);
when(-0.5) text='Baseline';
when(1) text='Cycle 1';
when(2) text='Cycle 2';
when(3) text='Cycle 3';
when(4) text='Cycle 4';
when(5) text='Cycle 5';
when(6) text='Cycle 6';
when(7) text='Cycle 7';
when(8) text='Cycle 8';
when(9) text='Cycle 9';
when(10) text='Cycle 10';
when(11) text='Cycle 11';
when(12) text='Cycle 12';
when(13) text='Cycle 13';
when(14) text='Cycle 14';
when(15) text='Cycle 15';
when(16) text='Cycle 16';
otherwise;
end;
end;
format freq fmt_freq. ;
if high<=0 then do;high=high-0.1;low=low-0.1;end;
if low>=0 then do;high=high+0.1;low=low+0.1;end;
run;
proc sgplot data=have7 noborder;
title 'Tagrisson 80 mg Chemotherapy ';
styleattrs datacolors=( yellow orange navy verylightblue) ;
highlow y=visit low=n_one high=n_zero/type=bar fillattrs=(color=verydarkgreen)
nooutline transparency=0.8 name='n' legendlabel='Never';
highlow y=visit low=p_zero high=p_one/type=bar fillattrs=(color=verydarkgreen)
nooutline transparency=0.8;
highlow y=visit low=low high=high/type=bar group=freq nooutline name='a';
/*scatter y=visit x=p1_p/markerchar=p1 markercharattrs=(size=8) x2axis;*/
/*scatter y=visit x=p2_p/markerchar=p2 markercharattrs=(size=8) x2axis;*/
text y=visit x=zero text=text/strip contributeoffsets=none splitchar=' ' splitpolicy=splitalways textattrs=(size=8);
/*yaxistable n1/y=visit location=outside position=left valueattrs=(size=8 ) VALUEJUSTIFY=right VALUEHALIGN=right ;*/
/*yaxistable n2/y=visit location=outside position=right valueattrs=(size=8) VALUEJUSTIFY=left VALUEHALIGN=left;*/
xaxis values=(-1.1 to 1.1 by 0.2) display=(nolabel noline) valuesdisplay=(
'100%' '80%' '60%' '40%' '20%' '0%' '0%' '20%' '40%' '60%' '80%' '100%') offsetmin=0 offsetmax=0 ;
x2axis values=(-1 -0.7 0 0.7 1) display=(nolabel noline noticks) valuesdisplay=(
' ' 'Patients Without Symp(%)' ' ' 'Patients Without Symp(%)' ' ') offsetmin=0 offsetmax=0 ;
yaxis reverse display=none ;
keylegend 'n' 'a' /title='Frequency:';
run;
If changing this percent.
proc sql; create table have2 as select visit,left,freq, count(*)/(select count(*) from have where visit=a.visit) as pct from have as a group by visit,left,freq ; quit;
Could get the following Graph.
@Ksharp The requirement is based on two treatment groups comparison and I had added my avalupdt variable in the group instead of freq as it is not giving me the desired output. Now the client requires separate output based on every param and i had tweaked your code slightly in the grouping to get the calculation based on aval, but not quite sure how do we segregate this between two treatment groups, as there no subgroup group available in sgplot. The below is my code that i had used. Can you please let me know where am i missing this.
proc format;
picture fmt
low-<0='000%' (mult=100)
0-high='000%' (mult=100)
;
value fmt_freq
1='Rarely'
2='Occasionaly'
3='Frequently'
4='Almost Constantly'
;
value $grade
'Severity'=1
'Frequency'=2
'Interference'=3
'Presence/Absence'=4
;
run;
proc sql;
create table ADQS4 as
select USUBJID,PARAM, PARAML,TYPEAE,VISLBL,TRTPN,AVALC,AVALUPDT, strip(put(AVALUPDT,8.)) as AVAL_c,
input(scan(PARAML,-1,'() '),best.) as freq from ANA.ADQS4
where pepfl="Y" and RANDFL='Y' /*and PARAML='Vomiting (10)'*/
AND TYPEAE NE 'Composite' AND AVISITN NOT IN(1301,1401) AND USUBJID EQ '1280-0022-1036002001';
quit;
data ADQS4_01;
set ADQS4;
if TYPEAE ='Severity' then type=1;
if TYPEAE ='Frequency' then type=2;
if TYPEAE ='Interference' then type=3;
if TYPEAE ='Presence/Absence' then type=4;
if freq=2 and TYPEAE ='Severity' then figno='01.01';
if freq=4 and TYPEAE ='Severity' then figno='01.02';
if freq=8 and TYPEAE ='Severity' then figno='01.03';
if freq=8 and TYPEAE ='Interference' then figno='01.04';
if freq=10 and TYPEAE ='Severity' then figno='01.05';
if freq=10 and TYPEAE ='Frequency' then figno='01.06';
if freq=11 and TYPEAE ='Severity' then figno='01.07';
if freq=11 and TYPEAE ='Frequency' then figno='01.08';
if freq=16 and TYPEAE ='Frequency' then figno='01.09';
if freq=17 and TYPEAE ='Severity' then figno='01.10';
if freq=17 and TYPEAE ='Frequency' then figno='01.11';
if freq=17 and TYPEAE ='Interference' then figno='01.12';
if freq=23 and TYPEAE ='Presence/Absence' then figno='01.13';
if vislbl='Baseline' then visit=-0.5;
if vislbl='Cycle 2' then visit=1;
if vislbl='Cycle 3' then visit=2;
if vislbl='Cycle 4' then visit=3;
if vislbl='Cycle 5' then visit=4;
if vislbl='Cycle 6' then visit=5;
if vislbl='Cycle 7' then visit=6;
if vislbl='Cycle 8' then visit=7;
if vislbl='Cycle 9' then visit=8;
if vislbl='Cycle 10' then visit=9;
if vislbl='Cycle 11' then visit=10;
if vislbl='Cycle 12' then visit=11;
if vislbl='Cycle 13' then visit=12;
if vislbl='Cycle 14' then visit=13;
if vislbl='Cycle 15' then visit=14;
if vislbl='Cycle 16' then visit=15;
run;
%macro graph(figno=,dsn=);
data ADQS4_1;
set ADQS4_01;
where figno=&figno.;
run;
proc sort data=ADQS4_1;by visit freq;run;
data ADQS4_1;
set ADQS4_1;
by visit freq;
left=first.freq ;
run;
proc sql;
create table ADQS4_2 as
select visit,left,freq,AVALUPDT,
count(*)/(select count(*) from ADQS4_1 where visit=a.visit) as pct
from ADQS4_1 as a
group by visit,left,freq,AVALUPDT;
quit;
data ADQS4_3;
set ADQS4_2;
by visit left;
if first.left then cum=0;
cum+pct;
run;
data ADQS4_4;
set ADQS4_3;
if left then cum=-cum;
run;
data ADQS4_5;
set ADQS4_4;
by visit left AVALUPDT;
lag_cum=lag(cum);
if first.left then lag_cum=0;
drop pct;
run;
data ADQS4_6;
set ADQS4_5;
if left then do;high=lag_cum;low=cum;end;
else do;high=cum;low=lag_cum;end;
drop cum lag_cum;
run;
data final_&dsn.;
set ADQS4_6;
by visit;
if first.visit then do;
n_one=-1.1;
n_zero=-0.1;
p_zero=0.1;
p_one=1.1;
p1_p=-0.9;
p2_p=0.9;
zero=0;
select(visit);
when(-0.5) text='Baseline';
when(1) text='Cycle 1';
when(2) text='Cycle 2';
when(3) text='Cycle 3';
when(4) text='Cycle 4';
when(5) text='Cycle 5';
when(6) text='Cycle 6';
when(7) text='Cycle 7';
when(8) text='Cycle 8';
when(9) text='Cycle 9';
when(10) text='Cycle 10';
when(11) text='Cycle 11';
when(12) text='Cycle 12';
when(13) text='Cycle 13';
when(14) text='Cycle 14';
when(15) text='Cycle 15';
when(16) text='Cycle 16';
otherwise;
end;
end;
figno=&figno.;
if high<=0 then do;high=high-0.1;low=low-0.1;end;
if low>=0 then do;high=high+0.1;low=low+0.1;end;
run;
%mend;
%graph(figno='01.01',dsn=G_1);
%graph(figno='01.02',dsn=G_2);
%graph(figno='01.03',dsn=G_3);
%graph(figno='01.04',dsn=G_4);
%graph(figno='01.05',dsn=G_5);
%graph(figno='01.06',dsn=G_6);
%graph(figno='01.07',dsn=G_7);
%graph(figno='01.08',dsn=G_8);
%graph(figno='01.09',dsn=G_9);
%graph(figno='01.10',dsn=G_10);
%graph(figno='01.11',dsn=G_11);
%graph(figno='01.12',dsn=G_12);
%graph(figno='01.13',dsn=G_13);
proc format;
value fmt_freq
2='Rarely'
4='Occasion'
8='Frequent'
10='Almost Constantly'
11='Almost 1'
16='Almost 2'
17='Almost 3'
23='Almost 4'
;
run;
proc format;
value fmt_fre
0='None'
1='Mild'
2='Moderate'
3='Severe'
4='Rarely'
5='Occassion'
;
run;
data final_g;
set final_g_:;
format avalupdt fmt_fre. ;
run;
proc sort data=final_g out=ANAT.FIG01;
by figno text freq;
run;
/*generaing graph*/
options leftmargin = 1.5cm rightmargin = 1.5cm topmargin = 1.5cm bottommargin = 2.0cm
formchar = '|----|+|---+=|-/<>*' nonumber nodate nocenter nomprint
orientation=landscape papersize=A4 dev=PNG300;
goptions XPIXELS=0 YPIXELS=0;
ods graphics on / reset = all width = 25.6cm height = 15.4cm noborder;
ods pdf file = "&outpath\BI9009A_F01_PRO_CTCAE_Stacked_BAR_Chart_v1_0.pdf"
pdftoc=1 compress=9 uniform nopdfnote nogtitle nogfootnote dpi=300 ;
proc sgplot data=final_g noborder;
Where figNo = "&figNo";
title 'Xenutuzumab with E+E Placebo with E+E ';
styleattrs datacolors=( yellow orange navy verylightblue) ;
highlow y=visit low=n_one high=n_zero/type=bar fillattrs=(color=verydarkgreen)
nooutline transparency=0.8 name='n' legendlabel='Never';
highlow y=visit low=p_zero high=p_one/type=bar fillattrs=(color=verydarkgreen)
nooutline transparency=0.8;
highlow y=visit low=low high=high/type=bar group=avalupdt nooutline name='a';
/*scatter y=visit x=p1_p/markerchar=p1 markercharattrs=(size=8) x2axis;*/
/*scatter y=visit x=p2_p/markerchar=p2 markercharattrs=(size=8) x2axis;*/
text y=visit x=zero text=text/strip contributeoffsets=none splitchar=' ' splitpolicy=splitalways textattrs=(size=8);
/*yaxistable n1/y=visit location=outside position=left valueattrs=(size=8 ) VALUEJUSTIFY=right VALUEHALIGN=right ;*/
/*yaxistable n2/y=visit location=outside position=right valueattrs=(size=8) VALUEJUSTIFY=left VALUEHALIGN=left;*/
xaxis values=(-1.1 to 1.1 by 0.2) display=(nolabel noline) valuesdisplay=(
'100%' '80%' '60%' '40%' '20%' '0%' '0%' '20%' '40%' '60%' '80%' '100%') offsetmin=0 offsetmax=0 ;
x2axis values=(-1 -0.7 0 0.7 1) display=(nolabel noline noticks) valuesdisplay=(
' ' 'Patients Without Symp(%)' ' ' 'Patients Without Symp(%)' ' ') offsetmin=0 offsetmax=0 ;
yaxis reverse display=none ;
keylegend 'n' 'a' /title='Frequency:';
ods pdf close;
I still can't figure out to get the number and percentage on the left and right side of the graph. I had tried to use this with sgpanel but not quite successful, some insights would be helpful please.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.