DATA Step, Macro, Functions and more

Group by and Sum only if value greater than a specific value

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Group by and Sum only if value greater than a specific value

I have the below sample datalike 

 

Product

Subsidiary

Stores

Sales

BootAddis Ababa12$29,761
Men's CasualAddis Ababa4$67,242
Men's DressAddis Ababa7$76,793
SandalAddis Ababa10$62,819
SlipperAddis Ababa14$68,641
Sport ShoeAddis Ababa4$1,690
Women's CasualAddis Ababa2$51,541
Women's DressAddis Ababa12$108,942
BootAlgiers21$21,297

 

I want to Group by data basis the Product but only for Subsidiaries where count of stores is > 10. Then I want Group by of Product with count of such store and total sales from such Products (where store count is >10).

 

How to do this in SAS?


Accepted Solutions
Solution
‎08-25-2016 04:40 PM
Super User
Posts: 19,822

Re: Group by and Sum only if value greater than a specific value

Then add the line after your FROM statement.

View solution in original post


All Replies
Super User
Posts: 19,822

Re: Group by and Sum only if value greater than a specific value

WHERE Stores > 10

 

This can be added to a SQL or PROC or Data step query. Which one are you intending to use?

New Contributor
Posts: 4

Re: Group by and Sum only if value greater than a specific value

Hi,

 

I want to add this to the Proc SQL

New Contributor
Posts: 4

Re: Group by and Sum only if value greater than a specific value

HI Reeza I want to add this inside the Proc Sql code
Solution
‎08-25-2016 04:40 PM
Super User
Posts: 19,822

Re: Group by and Sum only if value greater than a specific value

Then add the line after your FROM statement.

New Contributor
Posts: 4

Re: Group by and Sum only if value greater than a specific value

Thank you Reeza,

 

Its working, I got the mistake I was doing. Was adding where statement after Group By.

 

Thanks a lot

 

Regards

Ankush

☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 239 views
  • 1 like
  • 2 in conversation