Help using Base SAS procedures

Proc Report / horizontal column title

Accepted Solution Solved
Reply
Super Contributor
Posts: 357
Accepted Solution

Proc Report / horizontal column title

Please help with direct input in my code below.

 

-How to modify separate "Prevelance" cells into one single title style of "Prevalence"?

-How to left align the cell data?  

 

I would love to read complete SAS documentations to accomplish this but this time I run out of time so bad.

 

proc report data=have nofs headline headskip;
title "Table Title";
column year agecat bf_firstyear,pr_obs pr_obs=average;
define year/group width=4 'Year';
define agecat/group format=agecat. 'Age Groups'; 
define bf_firstyear/across 'Column title' format=format.; 
define pr_obs/display sum format=8.1 'Prevalence';
define average/analysis mean format=comma10.1 'Average';
run; 

Image shows my current output (data blurred).

 

sas support.png


Accepted Solutions
Solution
‎12-05-2017 07:05 AM
SAS Super FREQ
Posts: 817

Re: Proc Report / horizontal column title

You can change the order of the across and analysis variable in the COLUMN statement to achieve something similar. This allows you to have a common heading and suppress one heading using an empty label.

 

Have a look at the sample below.

 

/* 
 * default layout 
 */
proc report data=sashelp.cars;
  column type origin, invoice;
  define type / group;
  define origin / across;
  define invoice / analysis mean;
run;

/*
 * analysis before across var
 */
proc report data=sashelp.cars;
  column type invoice, origin;
  define type / group;
  define origin / across " ";
  define invoice / analysis mean "Invoice mean";
run;

View solution in original post


All Replies
Super User
Posts: 23,667

Re: Proc Report / horizontal column title

You can try LEFT/RIGHT on the DEFINE statement for alignment:

http://documentation.sas.com/?docsetId=proc&docsetTarget=p0wy1vqwvz43uhn1g77eb5xlvzqh.htm&docsetVers...

 

 

Solution
‎12-05-2017 07:05 AM
SAS Super FREQ
Posts: 817

Re: Proc Report / horizontal column title

You can change the order of the across and analysis variable in the COLUMN statement to achieve something similar. This allows you to have a common heading and suppress one heading using an empty label.

 

Have a look at the sample below.

 

/* 
 * default layout 
 */
proc report data=sashelp.cars;
  column type origin, invoice;
  define type / group;
  define origin / across;
  define invoice / analysis mean;
run;

/*
 * analysis before across var
 */
proc report data=sashelp.cars;
  column type invoice, origin;
  define type / group;
  define origin / across " ";
  define invoice / analysis mean "Invoice mean";
run;
Super Contributor
Posts: 357

Re: Proc Report / horizontal column title

Posted in reply to Bruno_SAS

Thank you. One more question please. Anyone knows how to order the appearance of column? I'd like to have NEVER column as the first column in the output table. It's the reference group.

SAS Super FREQ
Posts: 817

Re: Proc Report / horizontal column title

I suggest you start a new discussion with the appropriate title, makes it easier for everyone to find and answer to the question
Super User
Posts: 13,502

Re: Proc Report / horizontal column title


Cruise wrote:

Thank you. One more question please. Anyone knows how to order the appearance of column? I'd like to have NEVER column as the first column in the output table. It's the reference group.


In addition to @Bruno_SAS's suggestion of a new thread, Provide example data in the form of a data step and the proc format code to create your age category format.

The actual values of the variables and format options can interact in a number of ways to get things in a specific order and could actually require a proc sort before the report depending on the contents of those elements.

 

With example data in the form of data step code then tested solutions may be provided. Without data you'll tend to get guesses that may or may not work with your actual data.

☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 204 views
  • 1 like
  • 4 in conversation