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

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

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

View solution in original post

10 REPLIES 10
ChrisNZ
Tourmaline | Level 20

Do you use ODS PDF? Please provide your whole code.

 

monicluder
Fluorite | Level 6
No I don't use ODS PDF, I only use the print commando on the result window. I've posted all my code
FreelanceReinh
Jade | Level 19

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:

HTML_vs_Listing.png

 

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">&nbsp;</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.

ballardw
Super User

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.

monicluder
Fluorite | Level 6

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

ChrisNZ
Tourmaline | Level 20

@monicluder This looks like a defect. You should report it to SAS Tech support.

ChrisNZ
Tourmaline | Level 20

I reduced the code size and opened an incident with SAS.

Rogue <tr> tags are inserted.

monicluder
Fluorite | Level 6
Thanks Chris! I'm in low wifi area, now, and it's difficult for me communucating with my italian sas representative
DavidK_SAS
SAS Employee

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;

ChrisNZ
Tourmaline | Level 20
I agree. And while the syntax as valid, and while the listing output is correct, the defect is archived and will not be corrected for this reason: the syntax is atypical, and the common syntax works as expected.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

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
  • 10 replies
  • 1000 views
  • 9 likes
  • 5 in conversation