The SAS Output Delivery System and reporting techniques

proc report

Accepted Solution Solved
Reply
Regular Contributor
Posts: 158
Accepted Solution

proc report

I'm trying proc report code and it's truncated Total Open Issues on the table 

I hope I can find a way to display the whole string I tried to increase the length of site_number but it didn't work 

Please advise me 

 

this is the code that's I'm running 

proc report data=&Queries.2;
length SITE_NUMBER $25;
column SITE_NUMBER sitenum calcpct ;
define SITE_NUMBER/ display"Top 3 Sites with highest # issues";
define sitenum/ "# Open Issues";
define calcpct/ computed 'Percent' format=percent8.2;
compute after;
SITE_NUMBER='Total Open Issues';
endcomp;
COMPUTE before;
holdtot=sitenum.sum;
endcomp;
compute calcpct;
calcpct= sitenum.sum/ holdtot ;
endcomp;
rbreak after / summarize ;
run;

 

and this is my output

 Top 3 Sites with highest # issues # Open Issues Percent

1350735.00%
1601735.00%
1450630.00%
Total Open Issu20100.0%

Accepted Solutions
Solution
‎03-07-2018 11:35 AM
SAS Super FREQ
Posts: 9,365

Re: proc report

Hi:

Sorry, I missed the COMPUTE AFTER in your code. I only see a LENGTH statement inside the PROC REPORT step. I meant something like this:

report_long_text_rbreak.png

 

Notice how with Report #1, I only get the first letter of my COMPUTE AFTER string, because the length of the SEX variable in SASHELP.CLASS is $1. However, for #2 report, I am able to put "Gender Summary" as the text string at the end of the report because I have changed the length of the SEX variable in a DATA step program. There are a couple of other ways to solve this issue, but this is the most straightforward for beginners.

 

  Here's the code that generated the output above.

proc report data=sashelp.class;
  title '1) not big enough for AFTER text because length of SEX variable is only $1';
column sex n pctn age height;
define sex / group;
define n / 'Count';
define pctn / 'Percent' f=percent9.2;
define age / 'Avg Age' mean f=6.2;
define height / 'Avg Height' mean f=6.2;
rbreak after / summarize;
compute after;
  sex='Gender Summary';
endcomp;
run;

data newclass;
  length sex $15;
  set sashelp.class;
run;

proc report data=newclass;
  title '2) now length good for AFTER text';
column sex n pctn age height;
define sex / group;
define n / 'Count';
define pctn / 'Percent' f=percent9.2;
define age / 'Avg Age' mean f=6.2;
define height / 'Avg Height' mean f=6.2;
rbreak after / summarize;
compute after;
  sex='Gender Summary';
endcomp;
run;

Hope this explains what I mean about changing the length BEFORE the PROC REPORT step.

 

Cynthia

View solution in original post


All Replies
SAS Super FREQ
Posts: 9,365

Re: proc report

Hi:
The length of SITE_Number has to be increased BEFORE the PROC REPORT step. But I don't see where you are assigning the string "Total Open Issues" on the break and, although I see an RBREAK statement in your code, I don't see a COMPUTE AFTER block. How did you produce the output you show?

Also, no one can run your code because you have not provided your ODS statements or any data.

cynthia
Regular Contributor
Posts: 158

Re: proc report

Posted in reply to Cynthia_sas

Hi Cynthina, 

every thing is there in my code. I tried t increase the length by length statement and by format statement before proc report and it didn't work 

Solution
‎03-07-2018 11:35 AM
SAS Super FREQ
Posts: 9,365

Re: proc report

Hi:

Sorry, I missed the COMPUTE AFTER in your code. I only see a LENGTH statement inside the PROC REPORT step. I meant something like this:

report_long_text_rbreak.png

 

Notice how with Report #1, I only get the first letter of my COMPUTE AFTER string, because the length of the SEX variable in SASHELP.CLASS is $1. However, for #2 report, I am able to put "Gender Summary" as the text string at the end of the report because I have changed the length of the SEX variable in a DATA step program. There are a couple of other ways to solve this issue, but this is the most straightforward for beginners.

 

  Here's the code that generated the output above.

proc report data=sashelp.class;
  title '1) not big enough for AFTER text because length of SEX variable is only $1';
column sex n pctn age height;
define sex / group;
define n / 'Count';
define pctn / 'Percent' f=percent9.2;
define age / 'Avg Age' mean f=6.2;
define height / 'Avg Height' mean f=6.2;
rbreak after / summarize;
compute after;
  sex='Gender Summary';
endcomp;
run;

data newclass;
  length sex $15;
  set sashelp.class;
run;

proc report data=newclass;
  title '2) now length good for AFTER text';
column sex n pctn age height;
define sex / group;
define n / 'Count';
define pctn / 'Percent' f=percent9.2;
define age / 'Avg Age' mean f=6.2;
define height / 'Avg Height' mean f=6.2;
rbreak after / summarize;
compute after;
  sex='Gender Summary';
endcomp;
run;

Hope this explains what I mean about changing the length BEFORE the PROC REPORT step.

 

Cynthia

Regular Contributor
Posts: 158

Re: proc report

Posted in reply to Cynthia_sas
I changed both the length and the format to be able to display the result.
Thanks so much
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 246 views
  • 2 likes
  • 2 in conversation