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

Hello Everyone,

 

I have a dataset below showing variables country, salestype and number of sales. 

 

Countrysalestypesales
Europecar10
Europebike20
Europetruck30
Europebike12
Europecar20
Europebike25
Europetruck13
Europetruck32
Europebike42
Europecar52
UKcar32
UKbike45
UKtruck85
UKcar25
UKcar30
USbike56
USbike16
UScar13
Australiacar85
Australiabike63
Australiatruck78
Australiacar95
Australiabike45
Australiatruck25
Asiacar62
Asiatruck35
Asiabike15
Africacar29
Africacar36
Africabike78
Africabike95
Africacar45

 

I want the output such that it sums up the sales for each salestype and country and produces a table like below. 

 

 car salesbike salestruck salesTotal sales
Europe829975256
UK874585217
US1372 85
Australia180108103391
Asia621535112
Africa110173 283
Total sales5345122981344

 

 

Could you please guide me to code this. I tried using proc sql but it did not work the way I wanted. 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Here's one way to create a report with the right structure.  You can always learn more about PROC TABULATE if you want a fancier report:

 

proc tabulate data=have;

class country salestype;

var sales;

tables country all, (salestype all) * sales=' ' * sum=' ';

run;

View solution in original post

1 REPLY 1
Astounding
PROC Star

Here's one way to create a report with the right structure.  You can always learn more about PROC TABULATE if you want a fancier report:

 

proc tabulate data=have;

class country salestype;

var sales;

tables country all, (salestype all) * sales=' ' * sum=' ';

run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1 reply
  • 722 views
  • 3 likes
  • 2 in conversation