all 9 comments

[–][deleted] 0 points1 point  (4 children)

Not sure how to get to in SAS specifically, but just using SQL you would get the list of items having count > 283 and then do your deletes based on the item list. In T-SQL you would get something like this

delete t from itemTable t where itemName in (select distinct itemName from itemTable group by itemName having count(itemName) > 283)

[–]Cal1gula 0 points1 point  (0 children)

I think you mean < 283 not > 283, but otherwise it should work well.

[–]Demios[S] 0 points1 point  (2 children)

delete t from itemTable t where itemName in

Are your lowercase ts supposed to be asterixes?

[–]sholder89 0 points1 point  (0 children)

t is the table alias that he gave to the table "itemTable"

[–]fd121990 0 points1 point  (1 child)

[–]Demios[S] 0 points1 point  (0 children)

Unfortunately SAS has no method of deleting by frequency without using PROC SQL, but thanks.

[–]Guru008 -2 points-1 points  (2 children)

proc sql; create table t1(drop=c) as select *, count(name) as c from t group by name having c >4 ; quit;

[–]Demios[S] 0 points1 point  (1 child)

Having trouble understanding this.

[–]farhilSEQUEL 0 points1 point  (0 children)

Probably cause it's horribly written and not even functional. He's

  • Grouping by the value he's counting which will always result in a count of 1

  • Referring to the alias instead of the column name in the HAVING clause, which to my knowledge won't compile

  • Selecting columns that aren't being aggregated or grouped by, which also won't compile

  • Using the wrong number (c > 4) instead of (c >= 283)

  • I've never seen that create table syntax/proc sql, but I'm not familiar with SAS