I'm doing some listings using proc report, but I've got a problem.
If a variable has a length=5 but I put width=4 in proc report the output doesn't run as well as wanted. I would like to know if I can modify the length variable within proc report, because otherwise, I have to create a new variable in the dataset to predefine its length...
How can I do it? I hope you can help me!
"The output doesn't run as well as wanted" means that I would like to have a "perfect" line for each subject, but with the problem explained, there are some values that are in a line below the subject. I know that a way to solve this is to predefine all variables length and then assign new variables to old variables, but I would like to know if exists a faster way by using proc report options (like width, etc.). Thank you very much and I hope this new explanation will be clarifying.
P.S.: The code is something like this...
title4 "Listing 8. Quality of Life Questionnaire";
proc report data=qol headline headskip nocenter missing split='*' nowindows;
column ("__* *" (upatientid visit qolq qlitem1 qlitem2 qlitem3 qlitem4 qlitem5 qlitem6 qlitem7 qlitem8 qlitem9 qlitem10 qlitem11 qlitem12 qlitem13 qlitem14 qlitem15 qlitem16 qlitem17 qlitem18 qlitem19 qlitem20 qlitem21 qlitem22 qlitem23));
define upatientid / order order=data width=10 spacing=0 left 'Subject*identifier' flow;
define visit / display width=5 spacing=2 left 'Visit' flow;
define qolq / display width=30 spacing=2 left 'QoL done?' flow;
define qlitem1 / display width=7 spacing=2 left 'Stuffy/*Blocked*nose' flow;
define qlitem2 / display width=8 spacing=1 left 'Sneezing' flow;
define qlitem3 / display width=5 spacing=1 left 'Runny*nose' flow;
define qlitem4 / display width=5 spacing=1 left 'Itchy*nose' flow;
define qlitem5 / display width=5 spacing=1 left 'Itchy*eyes' flow;
define qlitem6 / display width=6 spacing=1 left 'Watery*eyes' flow;
define qlitem7 / display width=7 spacing=1 left 'Swollen*/Puffy*eyes' flow;
define qlitem8 / display width=4 spacing=1 left 'Sore*eyes' flow;
define qlitem9 / display width=5 spacing=1 left 'Rub*eyes&*nose' flow;
define qlitem10 / display width=4 spacing=1 left 'Blow*nose' flow;
define qlitem11 / display width=7 spacing=1 left 'Carry*tissues' flow;
define qlitem12 / display width=10 spacing=1 left 'Take*medication' flow;
define qlitem13 / display width=7 spacing=1 left 'Thirsty' flow;
define qlitem14 / display width=8 spacing=1 left 'Scratchy*/Itchy*nose' flow;
define qlitem15 / display width=8 spacing=1 left 'Headache' flow;
define qlitem16 / display width=7 spacing=1 left 'Playing*outside' flow;
define qlitem17 / display width=5 spacing=1 left 'Tired' flow;
define qlitem18 / display width=4 spacing=1 left 'Not*well*at*all' flow;
define qlitem19 / display width=9 spacing=1 left 'Irritable' flow;
define qlitem20 / display width=11 spacing=1 left 'Embarrassed' flow;
define qlitem21 / display width=6 spacing=1 left 'Hard to*get to*sleep' flow;
define qlitem22 / display width=8 spacing=1 left 'Wake up*at night' flow;
define qlitem23 / display width=9 spacing=1 left 'Pay*attention' flow;
where qlitem1-23 have a predefined length=8. Of course I would be able to put larger widths, but then this listing variables wouldn't appear in a single page. Thanx
I'm still not sure what you mean by a "perfect line". It seems to me that you want LISTING output. There are limitations to what you can do with WIDTH and FLOW in LISTING. I believe the sticking point in your example is the fact that if you make WIDTH=8 for everything, then your labels will be wrapped. Most of your labels will fit into 8 characters, except Irritable (9) or Embarassed (10). You should use WIDTH= to control the "uniformity" of the COLUMNS. That means WIDTH will have an impact on the column label. You can't have it both ways. Your best choice is to alter the labels and use a WIDTH=8 for all your QLITEM... variables.
Consider this data and program:
options linesize=180 nocenter;
charvar = 'ABCDEFGHIJKLMNOPQRSTUVWYXYZ';
charvar2 = 'ABCDEFGHIJKLMNOPQRSTUVWYXYZabcdefghijklmnopqrstuvwxyz';
charvar3 = 'ABCDEFGHIJKLMNOPQRSTUVWYXYZ';
charvar4 = 'ABCDEFGHIJKLMNOPQRSTUVWYXYZabcdefghijklmnopqrstuvwxyz';
proc report data=testit nowd;
title 'Proc Report -- WIDTH affects LABEL and VALUE';
title2 'Note uniform character width when WIDTH=8 or 10';
title3 'But also notice impact on Label when width=8';
column charvar charvar2 charvar3 charvar4;
define charvar / flow width=8 'Label....x';
define charvar2 / flow width=8 'Label....x';
define charvar3 / flow width=10 'Label....x';
define charvar4 / flow width=10 'Label....x';
It produces this output in LISTING. Notice how the columns widths are the same. However WIDTH=8 versus WIDTH=10 does have an impact on the column header labels:
*********************** OUTPUT *************************
Proc Report -- WIDTH affects LABEL and VALUE
Note uniform character width when WIDTH=8 or 10
But also notice impact on Label when width=8
If you need LISTING output, my recommendation would be to alter your column headers and use WIDTH=8 on your DEFINE statement. If you were using ODS, you would not even have to use the FLOW option. ODS HTML and ODS RTF and ODS PDF would automatically wrap the long text and you could control the cell width using the CELLWIDTH style attribute.
Yes, that's possible; however, the original requirement was to 1) use FLOW and 2) have EVERY column be EXACTLY the same WIDTH. At least, that's the way I interpreted the requirement for a "perfect" line.