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

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.)?

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

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

3 REPLIES 3
data_null__
Jade | Level 19

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.

Ksharp
Super User

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

Cynthia_sas
SAS Super FREQ

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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1280 views
  • 1 like
  • 4 in conversation