Hello! I'm trying to reproduce a table with some dimension and percentulals, but I've a problem with visualization; I post a sample code and the part o the result that I see; could anybody help me?
example data and code:
data t;input pat1 pat2 pat3 pat4 pat5 pat6 pat7 genere $ periodo $ cl_eta $ stato $;cards;
0 0 1 0 1 0 1 M periodo1 classe1 stato1
0 0 1 0 1 0 1 M periodo1 classe3 stato2
0 0 1 0 0 0 1 F periodo1 classe1 stato3
1 0 1 0 1 0 0 F periodo1 classe2 stato1
0 0 1 0 1 0 1 M periodo1 classe1 stato1
0 0 1 0 1 0 1 M periodo1 classe2 stato1
0 0 1 0 0 0 1 F periodo1 classe1 stato3
0 0 1 0 1 0 1 M periodo2 classe3 stato3
0 1 1 0 1 0 0 F periodo2 classe1 stato3
0 0 1 0 1 0 1 F periodo2 classe1 stato2
0 0 1 0 1 0 1 M periodo2 classe1 stato2
0 0 1 0 1 0 1 M periodo1 classe4 stato2
1 0 0 0 1 0 1 M periodo1 classe1 stato2
0 0 1 0 1 0 1 F periodo2 classe1 stato2
0 0 0 0 1 0 1 M periodo2 classe1 stato2
0 0 0 0 1 0 1 F periodo1 classe1 stato3
0 0 1 0 1 0 1 M periodo1 classe1 stato3
0 0 1 0 1 0 1 M periodo1 classe1 stato3
0 0 0 0 1 0 0 F periodo1 classe1 stato3
0 0 1 0 1 0 1 M periodo1 classe5 stato1
0 0 1 0 1 0 1 F periodo1 classe1 stato1
0 1 1 0 1 0 1 M periodo1 classe2 stato1
0 1 1 0 1 0 1 F periodo1 classe1 stato1
0 0 1 0 1 0 1 M periodo2 classe3 stato3
0 0 1 0 1 0 1 M periodo2 classe3 stato3
0 0 1 0 1 0 1 M periodo3 classe3 stato2
0 0 1 0 1 0 1 F periodo3 classe3 stato2
0 0 1 0 1 0 1 M periodo2 classe3 stato3
0 0 1 0 1 0 1 F periodo2 classe3 stato1
;
proc tabulate data=t; class periodo genere cl_eta stato;var pat1-pat7;
table periodo, cl_eta='Classe di età' *
(pat1*rowpctsum*f=8.2 pat2*rowpctsum*f=8.2 pat3*rowpctsum*f=8.2 pat4*rowpctsum*f=8.2 pat5*rowpctsum*f=8.2
pat6*rowpctsum*f=8.2 pat7*rowpctsum*f=8.2) *genere=' ', (stato=' ' all='totale'); keylabel rowpctsum=' ';
run;
In the result it is possible see that the variable "GENERE" is not aligned across all the rows of the table.
Thanks a lot
Monica
Try this and see if it is acceptable.
proc tabulate data=t; class periodo cl_eta stato; class genere ; var pat1-pat7; table periodo, cl_eta=' ' * (pat1-pat7)*genere=' '*rowpctsum*f=8.2 , stato=' ' all='totale' / row=float box="Classe di età"; keylabel rowpctsum=' '; run;
I think the issue is the mix of suppressed and unsuppressed column headers though not sure why.
Personally for my report I would be strongly tempted to have formats for Genere and Stato and use Preloadfmt so the row/columns are tad more consistent.
Hello @monicluder,
I can confirm that my SAS 9.4M5 produces the same corrupt table layout in HTML, whereas the listing output looks right.
As an example, here is the last page:
The HTML code created by SAS looks suspicious to me because the <tr> and </tr> tags are not balanced: 109 vs. 106 overall. (But I'm not an HTML expert.)
Example (part of the code for the table shown above):
<tr> <th class="l t rowheader" rowspan="14" scope="rowgroup">classe3 </th> <th class="l t rowheader" rowspan="2" scope="rowgroup">pat1</th> <th class="c rowheader" rowspan="2" scope="rowgroup"> </th> <tr> <th class="l t rowheader" scope="row">F </th> </tr> <tr> <th class="l t rowheader" scope="row">M </th> <td class="r b data">.</td> <td class="r b data">.</td> </tr>
I haven't tried other ODS destinations. A similar issue with the PDF destination was mentioned in this 2015 post.
If using ODS Listing is not an option and nobody else has a better idea, you might need to open a track with SAS Technical Support. Sorry I couldn't be of more help.
Try this and see if it is acceptable.
proc tabulate data=t; class periodo cl_eta stato; class genere ; var pat1-pat7; table periodo, cl_eta=' ' * (pat1-pat7)*genere=' '*rowpctsum*f=8.2 , stato=' ' all='totale' / row=float box="Classe di età"; keylabel rowpctsum=' '; run;
I think the issue is the mix of suppressed and unsuppressed column headers though not sure why.
Personally for my report I would be strongly tempted to have formats for Genere and Stato and use Preloadfmt so the row/columns are tad more consistent.
Thanks Ballardw, I'm agree with you. The first idea was about a bug, and it's indeed an abnormal result on my output report! Writing the code in the mode that you suggest, it's works!
Bye
Monica
@monicluder This looks like a defect. You should report it to SAS Tech support.
I reduced the code size and opened an incident with SAS.
Rogue <tr> tags are inserted.
TABULATE likes for analysis variables to follow class variables in TABLE statement dimension expressions. This worked for me:
proc tabulate data=t; class periodo genere cl_eta stato;var pat1-pat7;
table periodo, cl_eta='Classe di età' *genere=' '
*(pat1 pat2 pat3 pat4 pat5 pat6 pat7), (stato=' ' all='totale')*rowpctsum*f=8.2;
keylabel rowpctsum=' ';
run;
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 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.