The SAS Output Delivery System and reporting techniques

How to insert a blank line above and below for only one variable in proc report?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

How to insert a blank line above and below for only one variable in proc report?

Hi,

I am using a proc report to generate a summary. I would like to insert a blank line  above and below for only one variable and rest of them wihout any blank lines.

I am not able use  the headline for ODS RTF output. 

 

The format is some what like the below:

 

Header

----------

Space

Overall value

space

var1

var2

var3

------------ 

 

Thank you in advance.


Accepted Solutions
Solution
‎04-02-2017 08:24 PM
SAS Super FREQ
Posts: 8,814

Re: How to insert a blank line above and below for only one variable in proc report?

[ Edited ]

Hi: HEADLINE and HEADSKIP options are LISTING only options and will never work with RTF destinations or any destination that supports style. Those options were originally designed for the SAS output windows or "LST" output and were never carried forward into the world of ODS style.

Also, your code has STYLE=x.styles, which you do not provide.

It does not matter. There really isn't the concept of "lines" really, but you can insert spaces and if you use the textdecoration=underline or overline, you can mimic lines, but they will be in a proportional spaced font.

AND, when I try your code, even without the style, I get an error:
ERROR: Variable numobs is not on file WORK.CLASS3.

Does your code, as posted, work without errors?

 

  I'm not sure of your purpose for the PROC MEANS followed by the transpose. Many of the statistics you can get out of MEANS you can also request directly from PROC REPORt and/or PROC TABULATE.

 

  For example, consider this code that uses SASHELP.CLASS directly without MEANS/TRANSPOSE and uses the JOURNAL style (since you did not provide your style):

proc format;
  value $genfmt 'F' = 'Female'
               'M' = 'Male'
	       'T' = 'Total';
run;
  
ods rtf file='c:\temp\direct_report_stat.rtf' style=journal;

proc report data=sashelp.class;
  column sex n height,(sum mean max) weight,(sum mean max);
  define sex / group f=$genfmt.;
  define n / 'NumObs';
  define height / analysis;
  define weight / analysis;
  define sum / 'Sum' f=comma6.1;
  define mean / 'Mean' f=6.1;
  define max / 'Max' f=6.1;
  rbreak after / summarize;
  compute sex;
    if _break_ = '_RBREAK_' then do;
	   sex = 'T';
	end;
  endcomp;
run;
ods rtf close;

  And, output is (shown in RTF and HTML):

direct_report.png

cynthia

View solution in original post


All Replies
Super User
Posts: 11,104

Re: How to insert a blank line above and below for only one variable in proc report?

As a minimum you show code of what you have so far. Things interact in proc report and knowing things like the order of columns and such may help provide a solution. Better would be to include a data, in the form of a data step, so we can test against some of your data.

 

You can turn a SAS data set into data step code:Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

Occasional Contributor
Posts: 8

Re: How to insert a blank line above and below for only one variable in proc report?

Hi,
 
This is the sample code i have put it under. I want a line under the 'Total' and above and rest of them without any spaces.
 
data class;
set sashelp.class;
run;
 
proc means data=class nmiss sum;
class sex;
var height weight;
output out=class2 sum=;
run;
 
 
data class3;
length gender $8;
set class2;
gender=sex;
if _type_=0 and sex='' then do;
gender='Total';
end;
 
run;
 
proc transpose data=class3 out=trans4;
by sex;
var _numeric_;
id gender;
run;
 
ods rtf file='c:\test.rtf' style=x.styles;
proc report data=class3 headskip headline nowd split='*';
column  _type_ numobs  gender height weight ;
define numobs/  order order=internal noprint;
 
 
define gender/'Gender' display order order=internal style={cellwidth=5%};
define height/'Height' display order order=internal style={cellwidth=5%};
define weight/'Weight' display order order=internal style={cellwidth=5%};
 
run;
 
 
ods rtf close;
 
 
Thank you  in advance.
Solution
‎04-02-2017 08:24 PM
SAS Super FREQ
Posts: 8,814

Re: How to insert a blank line above and below for only one variable in proc report?

[ Edited ]

Hi: HEADLINE and HEADSKIP options are LISTING only options and will never work with RTF destinations or any destination that supports style. Those options were originally designed for the SAS output windows or "LST" output and were never carried forward into the world of ODS style.

Also, your code has STYLE=x.styles, which you do not provide.

It does not matter. There really isn't the concept of "lines" really, but you can insert spaces and if you use the textdecoration=underline or overline, you can mimic lines, but they will be in a proportional spaced font.

AND, when I try your code, even without the style, I get an error:
ERROR: Variable numobs is not on file WORK.CLASS3.

Does your code, as posted, work without errors?

 

  I'm not sure of your purpose for the PROC MEANS followed by the transpose. Many of the statistics you can get out of MEANS you can also request directly from PROC REPORt and/or PROC TABULATE.

 

  For example, consider this code that uses SASHELP.CLASS directly without MEANS/TRANSPOSE and uses the JOURNAL style (since you did not provide your style):

proc format;
  value $genfmt 'F' = 'Female'
               'M' = 'Male'
	       'T' = 'Total';
run;
  
ods rtf file='c:\temp\direct_report_stat.rtf' style=journal;

proc report data=sashelp.class;
  column sex n height,(sum mean max) weight,(sum mean max);
  define sex / group f=$genfmt.;
  define n / 'NumObs';
  define height / analysis;
  define weight / analysis;
  define sum / 'Sum' f=comma6.1;
  define mean / 'Mean' f=6.1;
  define max / 'Max' f=6.1;
  rbreak after / summarize;
  compute sex;
    if _break_ = '_RBREAK_' then do;
	   sex = 'T';
	end;
  endcomp;
run;
ods rtf close;

  And, output is (shown in RTF and HTML):

direct_report.png

cynthia

Super User
Posts: 9,856

Re: How to insert a blank line above and below for only one variable in proc report?

Make a dummy group variable.

 

data class;
 set sashelp.class;
 retain g 1;
run;

proc report data=class nowd;
column g sex weight;
define g/group noprint;
define sex/group;
define weight/sum;


compute before g;
line ' ';
endcomp;

compute before;
line ' ';
endcomp;
break before g/summarize;
run;

x.png

☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 245 views
  • 0 likes
  • 4 in conversation