BookmarkSubscribeRSS Feed
Naveen45
Fluorite | Level 6

In a dataset containing sales data with three different products on daily basis.

 

 

I want to calculate sales subtotal for each of the product grand total.

 

Looking for SAS code.

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Follow the guidance below the Post button - post example test data in the form of a datastep, use the {i} button above the post area to post code to retain formatting.  Show what you want out at the end.  Show logs/code you have done and where you are having diccifulties.  Avoid writing in bold an mixed colors.  

To do subtotals, you have several options, proc means, summary, proc sql sum() group by, datastep retain count variable.  They are each useful in different scenarios.

Finally this a Q&A forum not a contract work request page.

Astounding
PROC Star

Examine the data set that comes out of this:

 

proc summary data=have;

class product;

var amount;

output out=stats sum=;

run;

 

It will contain what you ask, but you will need to study a little to figure out the various pieces of the output.  If you want to use SAS, this is a tool you must master.

LinusH
Tourmaline | Level 20
Please don't store totals in a data set unless its only use will be for 1-1 report display.
Procedures like TABULATE and REPORT has this OOTB.
Data never sleeps

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 4343 views
  • 3 likes
  • 4 in conversation