The SAS Output Delivery System and reporting techniques

How to solve variable length problems in output using proc report

Reply
N/A
Posts: 0

How to solve variable length problems in output using proc report

Hello everyone!
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!
Ty!!!
Super Contributor
Super Contributor
Posts: 3,174

Re: How to solve variable length problems in output using proc report

Please explain "the output doesn't run as well as wanted." And also share your SAS code.

Scott Barry
SBBWorks, Inc.
SAS Super FREQ
Posts: 8,740

Re: How to solve variable length problems in output using proc report

Hi:
As explained in the Tech Support note, there are some PROC REPORT options that do NOT work with ODS destinations in the same way they work in the LISTING window (so if you are creating ODS HTML, ODS PDF or other ODS output), there would be no point to using WIDTH=, or HEADLINE, or DOL, etc
http://support.sas.com/kb/2/549.html
http://support.sas.com/kb/23/671.html
http://support.sas.com/rnd/base/ods/templateFAQ/report1.html

Also, I agree with Scott that your description of the problem is ambiguous -- more information is needed.

cynthia
N/A
Posts: 0

Re: How to solve variable length problems in output using proc report

"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;
run;

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
SAS Super FREQ
Posts: 8,740

Re: How to solve variable length problems in output using proc report

Hi:
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:
[pre]
title; footnote;
options linesize=180 nocenter;
data testit;
charvar = 'ABCDEFGHIJKLMNOPQRSTUVWYXYZ';
charvar2 = 'ABCDEFGHIJKLMNOPQRSTUVWYXYZabcdefghijklmnopqrstuvwxyz';
charvar3 = 'ABCDEFGHIJKLMNOPQRSTUVWYXYZ';
charvar4 = 'ABCDEFGHIJKLMNOPQRSTUVWYXYZabcdefghijklmnopqrstuvwxyz';
output;
run;

ods listing;

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';
run;

[/pre]

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 *************************
[pre]
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

Label... Label...
.x .x Label....x Label....x
ABCDEFGH ABCDEFGH ABCDEFGHIJ ABCDEFGHIJ
IJKLMNOP IJKLMNOP KLMNOPQRST KLMNOPQRST
QRSTUVWY QRSTUVWY UVWYXYZ UVWYXYZabc
XYZ XYZabcde defghijklm
fghijklm nopqrstuvw
nopqrstu xyz
vwxyz

[/pre]

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.

cynthia
Contributor
Posts: 74

Re: How to solve variable length problems in output using proc report

I think you may drop the width= statement for most of the variables, maybe only keep for those columns that you specifically need a width.
SAS Super FREQ
Posts: 8,740

Re: How to solve variable length problems in output using proc report

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.

cynthia
Ask a Question
Discussion stats
  • 6 replies
  • 170 views
  • 0 likes
  • 4 in conversation