Hello SAS Community,
Please anyone tell me why I'm getting an extra line of text when using compute before/after for 2 variables. Below is an example code.
Thank you!
data have;
input visit $ paramcd $ aval;
if find(paramcd, 'EQOL') gt 0 then gr=2;
else gr=1;
cards;
Screen EQOL0101 2
Screen EQOL0102 4
Screen EQOL0103 3
Screen EQOL0104 1
Screen EQOL0105 2
Screen PGIS 2
Screen CGIS 3
Week4 EQOL0101 2
Week4 EQOL0102 4
Week4 EQOL0103 3
Week4 EQOL0104 1
Week4 EQOL0105 2
Week4 PGIS 1
Week4 CGIS 2
Week4 PGIC 1
Week4 CGIC 2
Week8 EQOL0101 2
Week8 EQOL0102 4
Week8 EQOL0103 3
Week8 EQOL0104 1
Week8 EQOL0105 2
Week8 PGIS 1
Week8 CGIS 2
Week8 PGIC 1
Week8 CGIC 2
;
run;
proc report data=have;
column visit gr paramcd aval;
define visit/ order noprint;
define gr/ order noprint;
define paramcd/ 'Item' display;
define aval/'Value' display;
compute before visit/style={just=c};
line @1 text $40.;
length text $40;
if visit='Screen' then text='Screening';
else if visit='Week4' then text= 'Week 4';
else if visit='Week8' then text='Week 8';
endcomp;
compute before gr;
line @1 text $40.;
length text $40;
if gr=2 then text='EQ-5D-5L';
endcomp;
run;
Result:
Or you could try data _null_; suggest to use format $varying.
proc report data=have nowd;
column visit gr paramcd aval;
define visit/ order noprint;
define gr/ order noprint;
define paramcd/ 'Item' display;
define aval/'Value' display;
compute before visit/style={just=c};
line @1 text $40.;
length text $40;
if visit='Screen' then text='Screening';
else if visit='Week4' then text= 'Week 4';
else if visit='Week8' then text='Week 8';
endcomp;
compute before gr;
line @1 text $varying40. len;
length text $ 40;
len=0;
if gr=2 then do;len=10;text='EQ-5D-5L';end;
endcomp;
run;
You used TWO 'line' statement in two different computed blocks. Just combine these two computed blocks into ONE .
proc report data=have;
column visit gr paramcd aval;
define visit/ order noprint;
define gr/ order noprint;
define paramcd/ 'Item' display;
define aval/'Value' display;
compute before gr;
line @1 text $40.;
length text $40;
if visit='Screen' then text='Screening';
else if visit='Week4' then text= 'Week 4';
else if visit='Week8' then text='Week 8';
if gr=2 then text='EQ-5D-5L';
endcomp;
run;
Hi @Ksharp ,
Thank you for the suggestion. Interesting, VISIT is also a grouping variable that is handled inside another grouping variable GR. This eliminated the unnecessary extra row. Could we also keep the original justification of text in the report? VISITs are centered, GR is left justified. I tried with ods escapechar style elements, it didn't help.
ods escapechar='~';
proc report data=have;
column visit gr paramcd aval;
define visit/ order noprint;
define gr/ order noprint;
define paramcd/ 'Item' display;
define aval/'Value' display;
compute before gr/style={just=c};
line @1 text $40.;
length text $40;
if visit='Screen' then text='Screening';
else if visit='Week4' then text= 'Week 4';
else if visit='Week8' then text='Week 8';
if gr=2 then text="~S={just=left} EQ-5D-5L";
endcomp;
run;
Or you could try data _null_; suggest to use format $varying.
proc report data=have nowd;
column visit gr paramcd aval;
define visit/ order noprint;
define gr/ order noprint;
define paramcd/ 'Item' display;
define aval/'Value' display;
compute before visit/style={just=c};
line @1 text $40.;
length text $40;
if visit='Screen' then text='Screening';
else if visit='Week4' then text= 'Week 4';
else if visit='Week8' then text='Week 8';
endcomp;
compute before gr;
line @1 text $varying40. len;
length text $ 40;
len=0;
if gr=2 then do;len=10;text='EQ-5D-5L';end;
endcomp;
run;
Thank you @Ksharp for taking the time to look into the documentation and applying $varying format in my example.!
Very grateful to @data_null__ for the precious tips and guidance!
Appreciate your help, guys!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.