The row and column header values in a tabulate can be seen as coordinates, that is an intersection resulting in a cell that contains a single value.
The leftward shift of the cell values you want means there has been a change in what the class variables represent.
The layout of Table 2 requires the columns be based on a interval instead of year. You will need to compute that interval, and not label the columns as years,because that would be misleading, but label the columns as an interval.
I don't know French, so I made up my own sample data.
Suppose the data is recording the cost of cleanup for various sites cited for violations of environmental regulations.
data have;
do site_id = 1 to 1000;
citation_year = rand('integer', 2016, 2020);
cleanup_cost = rand('integer', 500, 1000);
do cleanup_year = citation_year to 2020;
cleanup_cost = rand('integer', 1, cleanup_cost); * simulate costs as always reducing as clean up proceeds;
output;
end;
end;
run;
ods html file='cost.html' style=plateau;
proc tabulate data=have format=dollar12.;
title "Table version 1";
class citation_year cleanup_year;
var cleanup_cost;
table
citation_year,cleanup_year * cleanup_cost * sum=''
;
run;
data have2;
set have;
years_since_citation = cleanup_year - citation_year; * compute the interval that will be tabulated in version 2;
run;
proc tabulate data=have2 format=dollar12.;
Title "Table version 2, with tricks";
class citation_year years_since_citation;
var cleanup_cost;
table
citation_year = ' ' /* trick: blank label causes empty row to never render */
,
years_since_citation
* cleanup_cost * sum=''
/
box = { /* trick: put label in box cell instead */
label='Citation Year'
style=[verticalalign=bottom]
}
;
run;
ods html close;
... View more