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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 3902 views
  • 3 likes
  • 4 in conversation