hello,
I am attempting to create the same report in SAS. Could you assist me in calculating the total and percentage for each equipment, as illustrated in the image? I've tried in SAS, but the result doesn't appear to be accurate. I aim for the subtotal to be 100%.
Thank you
thank you for your respond,
im using a cross tab with hierarchy column (epuipement + brand) and parc actif is my measure .
I have calculated Pourcentage by following these steps :
and adding subtotal to my crosstab.
is there any way to calculate the total of percent of the subtotal similar to the following crosstab
If you are using Visual Analytics 7.5x on SAS 9.4, then I'm afraid you are out of luck here. There is no way I'm aware of to get 100% for the subtotals in that release I'm afraid. This is due to the nature of that automatic calculated subtotals. You would have to do these calculations in your raw data before loading to LASR/Visual Analytics, then they would be have like normal measures rather than calculated aggregations, and would sum the way you are expecting.
If you are using SAS Viya however, there is a workaround. The automatic calculated subtotals does behave the same way here as it does in SAS 9.4, BUT there is an aggregated measure function called AggregateTable that will allow us to manually create the same calculation, and get the sum to work the way you would like.
To achieve this, you would need to create a calculated item that looks like this. I have substituted your column names so hopefully you can just copy and paste this into a new calculated item:
Sum [_ByGroup_] ('Parc actif'n) / AggregateTable(_Sum_, Table(_Sum_, Fixed('Categorie'n), 'Parc actif'n))
The first part, Sum [_ByGroup_] ('Parc actif'n), is just the normal sum for each Categorie/Operatuer combination.
The second part, AggregateTable(_Sum_, Table(_Sum_, Fixed('Categorie'n), 'Parc actif'n)) is the sum of just the Categorie data item.
And of course dividing the two gets us the subtotal.
Then when you turn on subtotals in the crosstab, it should get you that 100%. I've mocked up an example here using the SASHELP.CARS data with Origin, Type, and MSRP so you can see the difference:
Hopefully that helps you out!
Thank you for your response. Unfortunately, I am working with SAS VA 7.5 on SAS 9.4. Therefore, I will need to perform these calculations on my raw data before loading it into LASR/Visual Analytics.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.