BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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!!!
11 REPLIES 11
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Please explain "the output doesn't run as well as wanted." And also share your SAS code.

Scott Barry
SBBWorks, Inc.
Cynthia_sas
SAS Super FREQ
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
deleted_user
Not applicable
"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
Cynthia_sas
SAS Super FREQ
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
jonna28pr0
Fluorite | Level 6

Hi Cynthia,

 

I tried your listing program. Am still not able to see the changes done by FLOW and WIDTH options.. Am i missing out anything here? BTW am not trying ODS outputs. Your suggestions would help me a lot. Thanks.

 

Below is the program i tried:

 

options linesize=180;
data learn.lengthy_text;
charvar = 'ABCDEFGHIJKLMNOPQRSTUVWYXYZ';
charvar2 = 'ABCDEFGHIJKLMNOPQRSTUVWYXYZabcdefghijklmnopqrstuvwxyz';
charvar3 = 'ABCDEFGHIJKLMNOPQRSTUVWYXYZ';
charvar4 = 'ABCDEFGHIJKLMNOPQRSTUVWYXYZabcdefghijklmnopqrstuvwxyz';
output;
run;
proc report data = learn.lengthy_text;
define charvar / flow width = 10  'Label....x';
run;

Cynthia_sas
SAS Super FREQ

Hi:

  It's not a good idea to bury your new comment in a 9 year old posting. I almost didn't see it. What might work better is to make a new posting and just give a link to the older posting. In order to see the changes for the FLOW and WIDTH options, you have to make some changes in the original program I posted. For example, if I leave FLOW off of the DEFINE statement for CHARVAR2 and CHARVAR4, then you see this:

with_without_flow.png

 

On the other hand, if I change the value for WIDTH=, then you see THIS:

diff_width.png

I believe that if you change the values of WIDTH and then change having FLOW or not, you'll see the difference. But I really think you need to run the original program, as I posted it and make your changes to THAT program. You can't see the difference using only 1 variable on the report.

 

Hope this helps,

Cynthia

jonna28pr0
Fluorite | Level 6

Thanks for helping me out and yes I agree, I didn't notice the post's date 🙂 Will pay more attention next time before posting.

 

Coming to the problem, I tried your original program and did try the flow option and width option separately. Still am not able to see the changes. I am using SAS University edition for learning purpose. Will that be a problem?

 

This is the listing i keep getting,

my listing for your program.PNG

 

 

 

Cynthia_sas
SAS Super FREQ

Hi:

  Yes, of course that's the reason. FLOW and WIDTH are LISTING-only options. When you use SAS University Edition, the default output is ODS HTML output -- that IS using ODS. You said in your original post that you were NOT interested in ODS, so I thought you had turned LISTING output ON.

 

  If you notice, your output, from SAS University Edition has colors and fonts being used; on the other hand, my output appears without any fancy colors or interior table lines and is in a "fixed pitch" font. That shows you how ODS destinations completely IGNORE options like FLOW and WIDTH that are LISTING-only options.

 

  It would have been helpful to mention that you were using University Edition in your original post. If you did, I must have missed it. However, SAS University Edition does not automatically create ODS LISTING results, since there is not any LISTING window for viewing ASCII text output. You'd have to change the code to see the results by explicitly saving the LISTING output to a file and then opening the file.

 

  However, why did you say you did not want to know about ODS output if you really ARE generating ODS HTML output from SAS University Edition? If FLOW and WIDTH are ignored by ODS  when you run PROC REPORT code and if you want to keep getting the default output from SAS University Edition, then you should NOT use FLOW and WIDTH, the default destination for SAS University Edition does NOT use those options, as you have proved with a comparison of your screen shot to my screen shot. My screen shot is of the LISTING output and shows how FLOW and WIDTH are used, but ONLY by the LISTING destination. Your screen shot, is of ODS HTML output and shows that FLOW and WIDTH are ignored.

 

  If you want to see the output, you'll have to explicitly use the ODS LISTING  statement with a FILE= options, writing to /folders/myfolders, as shown below:

ods listing file='/folders/myfolders/LISTING_showout.txt';
proc report data = lengthy_text;
title 'Proc Report -- WIDTH affects LABEL and VALUE';
title2 'Note difference in display of values with FLOW ';
title3 'But specifying different WIDTH values';
column charvar charvar2 charvar3 charvar4;
define charvar / flow width=8 'Label....x';
define charvar2 / flow width=16 'Label....x';
define charvar3 / flow width=10 'Label....x';
define charvar4 / flow width=20 'Label....x';
run;

Then, after you created the LISTING_showout.txt file -- you'll have to find it in your FILES and Folders list and open it. SAS Studio will NOT open it for you automatically.

 

  Hope this explains the difference.

Cynthia

 

 

jonna28pr0
Fluorite | Level 6

Thanks Cynthia. Yes now am able to see the differences. I haven't clearly understood the difference between Listing and ODS outputs. That explains everything. 

abdullala
Calcite | Level 5
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.
Cynthia_sas
SAS Super FREQ
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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 11 replies
  • 2891 views
  • 2 likes
  • 5 in conversation