Fluorite | Level 6

## 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

1 ACCEPTED SOLUTION

Accepted Solutions
Tourmaline | Level 20

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

``````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;``````
7 REPLIES 7
Tourmaline | Level 20

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

what numerical value does 2,80,000 represent?

Don't quite get the punctuation 🙂

Fluorite | Level 6

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

Hi,

The sales price is in INR (Rs).

Thanks !

Super User

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

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

Fluorite | Level 6

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

what if there's no comma ?

Consider the sales price as - Rs. 228000.

Same for all the rest.

Thanks !

Super User

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

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

Tourmaline | Level 20

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

``````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;``````
Fluorite | Level 6

## 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. 🙂

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