## Find a Count of branches based on sales

Solved
Occasional Contributor
Posts: 7

# Find a Count of branches based on sales

Hi,

I'm stuck with the coding part for this particular dataset.

Kindly help.

---------------------------------------------------------------------------------------------------------------------------------------

We have a branch sales data in below table, read this dataset and then categorize and find count of branches on basis of sales.

Sales can be categorized as

 Category Sales description Low Sales < 2,00,000 Medium 2,00,000 < sales < 3,00,000 High 3,00,000 < sales < 4,00,000 Exceptional Sales > 4,00,000

 Branch sales 1 2,80,000 2 1,50,000 3 4,50,000 4 3,20,000 5 2,22,000 6 1,75,000 7 5,00,343 8 2,63,000 9 1,15,000 10 2,55,000

Thanks in advance.

Accepted Solutions
Solution
‎03-11-2018 07:18 AM
PROC Star
Posts: 1,400

## Re: Find a Count of branches based on sales

Posted in reply to HarshaChaube
``````data have;
input Branch sales;
datalines;
1 280000
2 150000
3 450000
4 320000
5 222000
6 175000
7 500343
8 263000
9 115000
10 255000
;

proc sql;
create table want as
select case when sales < 200000 then 'Low'
when 200000 <= sales < 300000 then 'Medium'
when 300000 <= sales < 400000 then 'High'
else 'Exceptional'
end as Category
,count(calculated Category) as Count
from have
group by calculated Category;
quit;``````

All Replies
PROC Star
Posts: 1,400

## Re: Find a Count of branches based on sales

Posted in reply to HarshaChaube

what numerical value does 2,80,000 represent?

Don't quite get the punctuation

Occasional Contributor
Posts: 7

## Re: Find a Count of branches based on sales

Hi,

The sales price is in INR (Rs).

Thanks !

Super User
Posts: 10,570

## Re: Find a Count of branches based on sales

Posted in reply to HarshaChaube

2,28,000 is not recognized by SAS as a number. Providing data in a data step will immediately show you that.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 7

## Re: Find a Count of branches based on sales

Posted in reply to KurtBremser

what if there's no comma ?

Consider the sales price as - Rs. 228000.

Same for all the rest.

Thanks !

Super User
Posts: 10,570

## Re: Find a Count of branches based on sales

Posted in reply to HarshaChaube

Please provide example data for testing in a data step with datalines, and show the code you already have.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Solution
‎03-11-2018 07:18 AM
PROC Star
Posts: 1,400

## Re: Find a Count of branches based on sales

Posted in reply to HarshaChaube
``````data have;
input Branch sales;
datalines;
1 280000
2 150000
3 450000
4 320000
5 222000
6 175000
7 500343
8 263000
9 115000
10 255000
;

proc sql;
create table want as
select case when sales < 200000 then 'Low'
when 200000 <= sales < 300000 then 'Medium'
when 300000 <= sales < 400000 then 'High'
else 'Exceptional'
end as Category
,count(calculated Category) as Count
from have
group by calculated Category;
quit;``````
Occasional Contributor
Posts: 7

## Re: Find a Count of branches based on sales

I'm new to this and have never used ",count".

``,count(calculated Category) as Count``

Thank you.

☑ This topic is solved.

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

Discussion stats
• 7 replies
• 171 views
• 1 like
• 3 in conversation