DATA Step, Macro, Functions and more

Create a Report

Accepted Solution Solved
Reply
Contributor
Posts: 44
Accepted Solution

Create a Report

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. 


Accepted Solutions
Solution
‎05-19-2016 02:55 PM
Super User
Posts: 5,085

Re: Create a Report

[ Edited ]

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


All Replies
Solution
‎05-19-2016 02:55 PM
Super User
Posts: 5,085

Re: Create a Report

[ Edited ]

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;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 174 views
  • 3 likes
  • 2 in conversation