BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
new510
Fluorite | Level 6

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

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

4 REPLIES 4
ballardw
Super User

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.

new510
Fluorite | Level 6
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.
Cynthia_sas
SAS Super FREQ

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

Ksharp
Super User

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 6609 views
  • 0 likes
  • 4 in conversation