I am tasked with a problem to solve. I have a report with 4 columns. Each cell can have multiple rows. I need to rows to line up in the columns. Everything is fine until I hit a row which as to wrap. From that point on, the rows in the other columns are off by one. This is the code:
DATA overmas3;
*FILE mout; RETAIN minus -1;
length prot_field $ 100
pat_field $ 60
exp_field
late_field $ 2000
mat_field $ 2000
item_field $ 2000;
SET overdu END=enda; BY dc_num;
ARRAY forms(500) form1-form500;
ARRAY folds(500) fold1-fold500;
ARRAY whicho(500) which1-which500;
ARRAY dayl(500) day1-day500;
ARRAY exp(500) exp1-exp500;
prot_field = TRIM(LEFT(dc_num)) || ' \n \n' ||
TRIM(LEFT(dm_rb)) || ' \n' ||
TRIM(LEFT(phone)) || ' \n' ||
TRIM(LEFT(sa)) || ' \n' || /*Added per Rave Project */
TRIM(LEFT(saqc));
pat_field = TRIM(LEFT(dcntr_id)) || ' \n \n' ||
TRIM(LEFT(intl)) || ' \n' ||
TRIM(LEFT(rmbr_id)) || ' \n' ||
TRIM(LEFT(PUT(date_on,MMDDYY10.))) || ' \n' ||
TRIM(LEFT(PUT(fu_date,MMDDYY10.)));
mat_field = '';
item_field = '';
exp_field = '';
late_field = '';
DO I=1 to 500;
IF forms(I)^='' THEN
DO;
/* IF I=1 THEN mat_field = TRIM(LEFT(forms(I)))|| foldr;
ELSE mat_field = TRIM(LEFT(mat_field)) ||'\n'|| '\n' || TRIM(LEFT(forms(I)))|| foldr; */
IF I=1 THEN mat_field = catx (',',folds(I), forms(I));
ELSE mat_field = TRIM(LEFT(mat_field)) ||'\n'|| '\n' ||catx(',', folds(I),forms(I));
IF I=1 THEN item_field = TRIM(LEFT(whicho(I)));
ELSE item_field = TRIM(LEFT(item_field)) || '\n' || '\n' || TRIM(LEFT(whicho(I)));
IF I=1 THEN exp_field = TRIM(LEFT(PUT(exp(I),MMDDYY10.)));
ELSE exp_field = TRIM(LEFT(exp_field)) || '\n' ||'\n' || TRIM(LEFT(PUT(exp(I),MMDDYY10.)));
IF I=1 THEN late_field = TRIM(LEFT(PUT(dayl(I),5.)));
ELSE late_field = TRIM(LEFT(late_field)) || '\n' || '\n' || TRIM(LEFT(PUT(dayl(I),5.)));
END;
END;
RUN;
This is the report code:
TITLE1 j=center "&otitle";
TITLE2 j=center "&pmem &ploc";
TITLE3 j=center "&thirty &sixty &ninety ";
FOOTNOTE j=right "Created on: &pdat";
OPTIONS NOBYLINE NUMBER PAGENO=1 NODATE;
PROC REPORT DATA=overmas3 NOWINDOWS spanrows center headskip headline style(header)=[font_size=9pt font_weight=bold]
style(report)=[borderwidth=1pt cellpadding=2pt cellspacing=0 rules=all font_size=9pt] ;
BY dc_num;
COLUMN prot_field pat_field mat_field item_field exp_field late_field;
DEFINE prot_field / order style=[outputwidth=1.0in just=l fontsize=8pt] 'Protocol\n\nQCS\nPhone\nSA\nSAQC';
DEFINE pat_field / display style=[outputwidth=1.0in just=l fontsize=8pt]
'Patient\n\nInitials\nLocalID\nDate On\nLast Contacted';
DEFINE mat_field / display style=[outputwidth=2.50in just=l fontsize=8pt] 'Material';
/*--- if mat_field > 2.5 inches we need to move the following 3 fields down 1 line for each 2.5 of material ---*/
DEFINE item_field / display style=[outputwidth=1.75in just=l fontsize=8pt] 'Items';
DEFINE exp_field / display style=[outputwidth=.9in just=c fontsize=8pt] 'Expected';
DEFINE late_field / display style=[outputwidth=.4in just=c fontsize=8pt] 'Days/Late';
RUN;
I have attached a copy of a snapshot of the report. You can see that wnen the first line wraps, the row in the second column for the second row is not longer lining up.
I use proc print a lot, but I am not to familiar with proc report.
Upon further investigation, it appears that Adobe is doing the line wrapping, so SAS has no idea that it happened. I have decided to create 3 reports: 1 in landscape with the columns wide enough to not require wrapping; 1 in portrait with the font reduced enough to not require wrapping; and 1 in Excel which, because of the cells, would keep everything lined up. I will present each of these options to the user and let them decide what to do.
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.
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.