Help using Base SAS procedures

PROC Report Across Columns

Accepted Solution Solved
Reply
Contributor
Posts: 53
Accepted Solution

PROC Report Across Columns

I have code which produces a report where the number of columns may vary based upon the dataset using the ACROSS specification. Column grand totals are stored in unique macro variables GT_1 .... GT_x for as many columns as exist in the data. My question is, with a varying number of columns, is there any way to place the GT_x values above those columns (e.g., (N = 234), etc.)?


Accepted Solutions
Solution
‎09-03-2012 11:07 AM
SAS Super FREQ
Posts: 8,862

Re: PROC Report Across Columns

Hi:

  It is possible to do you you want because you can nest ACROSS variables under other ACROSS variables in order to get another level of variable -- which gives you another level of header. The fact that you are creating macro variables suggests that you have some degree of macro knowledge. Possibly something like a user-defined format might work, using CNTLIN, as already suggested.

  Without more information from you, like seeing your existing code or getting an idea of your data in more detail, it's hard to provide specific advice.

 

  Here's a very simple example, that uses a DATA step program to make the "extra" header variable from a macro variable and then uses the NOCOMPLETECOLS option of PROC REPORT to get only 1 header above every unique value of AGE. See attached screenshot.
 

cynthia


agehdr.png

View solution in original post


All Replies
Respected Advisor
Posts: 3,799

Re: PROC Report Across Columns

I would create a value label format for the values of ACROSS that includes N=.  This can be done using a data step to create a CNTLIN data set for PROC FORMAT.  This will provide a data driven solution that will be flexable based on the number of levels in the ACROSS variable.

Super User
Posts: 10,020

Re: PROC Report Across Columns

I am afraid it is hard for proc report ,but it maybe easy for data step. What is your sample data and output you like ?

Ksharp

Solution
‎09-03-2012 11:07 AM
SAS Super FREQ
Posts: 8,862

Re: PROC Report Across Columns

Hi:

  It is possible to do you you want because you can nest ACROSS variables under other ACROSS variables in order to get another level of variable -- which gives you another level of header. The fact that you are creating macro variables suggests that you have some degree of macro knowledge. Possibly something like a user-defined format might work, using CNTLIN, as already suggested.

  Without more information from you, like seeing your existing code or getting an idea of your data in more detail, it's hard to provide specific advice.

 

  Here's a very simple example, that uses a DATA step program to make the "extra" header variable from a macro variable and then uses the NOCOMPLETECOLS option of PROC REPORT to get only 1 header above every unique value of AGE. See attached screenshot.
 

cynthia


agehdr.png
🔒 This topic is solved and locked.

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

Discussion stats
  • 3 replies
  • 301 views
  • 1 like
  • 4 in conversation