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. 🙂
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;
what numerical value does 2,80,000 represent?
Don't quite get the punctuation 🙂
Hi,
The sales price is in INR (Rs).
Thanks !
2,28,000 is not recognized by SAS as a number. Providing data in a data step will immediately show you that.
what if there's no comma ?
Consider the sales price as - Rs. 228000.
Same for all the rest.
Thanks !
Please provide example data for testing in a data step with datalines, and show the code you already have.
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;
I'm new to this and have never used ",count".
,count(calculated Category) as Count
Thank you. 🙂
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.
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.