Proc report: unknown number of columns

Posts: 32

Proc report: unknown number of columns


I create Proc Report based on a dataset with consecutive numeric variables whose names and number are not know in advance .

Based on the value of the last column I want to color the numeric cells (in each row)

I've made some trials with arrays and numbered columns in the compute statement but don't get the expected results

Any help will be highly appreciated


Super Contributor
Posts: 644

Re: Proc report: unknown number of columns

For a start you can use Proc SQL with the meta table Dictionary.columns to find all the columns and their order.  That should enable you to identify the last column and the number of columns.  Creating macro variables for these data (updated for each run of the program) might be all you need to create your report.


Posts: 9,371

Re: Proc report: unknown number of columns


It's sort of hard to imagine what your data looks like. If you don't know the names and/or how many columns there are, how are you going to code the compute block that you need? What do you know about your data? Can you post a sample dataset and an example of the code that you've tried that doesn't work? Also, the destination that you want the output sent to?

  You're going to have a challenge because I think you may have to get into the use of macro variables in order to build your CALL DEFINE statements. You can color code variables, but you will need to list them in a DEFINE statement or a CALL DEFINE statement. And you will need a variable name to do that.

  You can try something like the program shown below, but you it is not going to allow you much processing control without being able to use variable names (no break processing, no compute block control.


ods html file='c:\temp\color_numeric.html' style=sasweb;

proc report data=sashelp.class nowd;

  column _character_ _numeric_;

  define _character_ / style(column)={background=pink};

  define _numeric_ / style(column)={background=yellow};


ods html close;

Posts: 32

Re: Proc report: unknown number of columns

Posted in reply to Cynthia_sas

Some more details

The table below is actually a dataset produced by a proc transpose. The bold columns headers are produced automatically by the proc based on labels in the original dataset (before transpose). What I need is to color the numeric cells in each row based on some values of TRIG in the same row

DimensionKUKU_1                JJJ-RT                 Depnt_CCC__n_58_ TRIG
My team4.384.124.364.5
My job3.823.904.053.2
WLB-Work Life Balance3.733.573.724.6



Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation