In proc report, I am having difficulty getting the indentation before second level (High Level Term 1) or third level and so on.
When I use style(column)=[cellwidth=6.5 cm JUST=LEFT asis=on], I get indentation but the continuous next line starts from the beginning because of the sentence length. Eg:
Is there a way to get indentation aligned for different level?
Here is my proc report program:
proc report data=final nowindows split='~' headline headskip contents='' formchar(2)='_' missing spacing=1;
*by seq seq_c1 seq_trt;
columns sqn seq ord cat _c1 - _c6;
define sqn / group order=data noprint;
define seq / group order=data noprint;
define ord /display order=data noprint;
define cat / display order=data style(column)=[cellwidth=6.5 cm JUST=LEFT asis=on] style(header)=[JUST=LEFT] flow ;
define _c1 / display order = data style(column)=[cellwidth=2.8 cm JUST=LEFT] style(header)=[JUST=Center] ;
define _c2 / display order = data style(column)=[cellwidth=2.8 cm JUST=LEFT] style(header)=[JUST=Center];
define _c3 / display order = data style(column)=[cellwidth=2.8 cm JUST=LEFT] style(header)=[JUST=Center];
define _c4 / display order = data style(column)=[cellwidth=2.8 cm JUST=LEFT] style(header)=[JUST=Center];
define _c5 / display order = data style(column)=[cellwidth=2.8 cm JUST=LEFT] style(header)=[JUST=Center];
define _c6 / display order = data style(column)=[cellwidth=2.8 cm JUST=LEFT] style(header)=[JUST=Center];
compute cat;
if ord=3 then do; cat=' '||cat; end;
if ord=4 then do; cat=' '||cat; end;
endcomp;
compute after sqn;
line '';
endcomp;
run;
Thank you.
Here is a small code to generate data:
data check;
length sqn 8. cat $100.;
input sqn cat $;
datalines;
1 Uncoded
2 Uncoded
3 ABNORMAL-MENSTRUATION-DIAGNOSTIC-CURETTAGE-OF-THE-UTERINE-CAVITY.
3 ANXIETY
3 CARPAL-TUNNEL-SYNDROME
3 EXACERBATION
;
run;
I would solve this by using the actual style elements, rather than manually adding spaces. Here LEFTMARGIN
is probably the right way to go, although there is an INDENT
style that sometimes is preferable; I think LEFTMARGIN
gets you what you want.
You can see some questions on http://communities.sas.com, like this one, with similar requests and answers (I used that question as a reference for this answer).
data check;
length sqn 8. cat $100 _c1-_c6 $16;
array _c[6] $ (6*"TestingText");
input sqn cat $;
seq=_n_;
ord = _n_;
datalines;
1 Uncoded
2 Uncoded
3 ABNORMAL-MENSTRUATION-DIAGNOSTIC-CURETTAGE-OF-THE-UTERINE-CAVITY.
3 ANXIETY
3 CARPAL-TUNNEL-SYNDROME
3 EXACERBATION
;
run;
ods pdf file="c:\temp\test.pdf";
proc report data=check nowindows split='~' headline headskip contents='' formchar(2)='_' missing spacing=1;
*by seq seq_c1 seq_trt;
columns sqn seq ord cat _c1 - _c6;
define sqn / group order=data noprint;
define seq / group order=data noprint;
define ord /display order=data noprint;
define cat / display order=data style(column)=[cellwidth=6.5 cm JUST=LEFT asis=on] style(header)=[JUST=LEFT] flow ;
define _c1 / display order = data style(column)=[cellwidth=2.8 cm JUST=LEFT] style(header)=[JUST=Center] ;
define _c2 / display order = data style(column)=[cellwidth=2.8 cm JUST=LEFT] style(header)=[JUST=Center];
define _c3 / display order = data style(column)=[cellwidth=2.8 cm JUST=LEFT] style(header)=[JUST=Center];
define _c4 / display order = data style(column)=[cellwidth=2.8 cm JUST=LEFT] style(header)=[JUST=Center];
define _c5 / display order = data style(column)=[cellwidth=2.8 cm JUST=LEFT] style(header)=[JUST=Center];
define _c6 / display order = data style(column)=[cellwidth=2.8 cm JUST=LEFT] style(header)=[JUST=Center];
compute cat;
if ord=3 then call define('cat','style','style={leftmargin=0.1in}');
if ord=4 then call define('cat','style','style={leftmargin=0.2in}');
endcomp;
compute after sqn;
line '';
endcomp;
run;
ods pdf close;