BookmarkSubscribeRSS Feed
q1234
Calcite | Level 5
Hi

Any one can you help with this? I used to use this code to remove less than 10 observations in the same year and industry and it works. But I need to create a dataset for each year and the run the code.

So, can you help me to modify this code to run it for pooled sample including all the years?

Thanks




the dataset
Firm industry year
x 22 2001
z 33 2002
v 33 2002
b 14 2005
w 22 2001
x 22 2002
x 22 2003


The code

proc sort data=data;
by industry;
run;

proc tabulate data=dataset out= dataset_1;
class industry;
table industry*n;
run;

data dataset_1;
set dataset_1;
drop _table_;
drop _page_;
drop _type_;
run;


proc sort data= dataset;
by industry;
run;

proc sort data= dataset_1;
by industry;
run;

data dataset_2;
merge dataset dataset_1;
by industry;
run;

data dataset_3;
set dataset_2;
if n < 10 then delete;
run;
--------------------------------------------------------------
4 REPLIES 4
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello q1234,

This is a possible solution:
[pre]
proc freq data=data noprint;
tables Industry*Year /out=f (where=(count > 10));
run;
proc SQL;
create table r as
select a.*
from data as a, f as b
where a.year=b.year and a.industry=b.industry
;quit;
[/pre]
Sincerely,
SPR
q1234
Calcite | Level 5
Many thanks
FriedEgg
SAS Employee
> data dataset_3;
> set dataset_2;
> if n < 10 then delete;
> run;



data dataset_3;
set dataset_2;
if _n_ < 10 then delete;
run;
Cynthia_sas
SAS Super FREQ
Hi:
An aside comment...if all you want to do is drop variables from the OUT= dataset, then this is OK syntax:
[pre]
proc tabulate data=dataset
out=dataset_1(drop=_table_ _type_ _page_);
class industry;
table industry*n;
run;
[/pre]

cynthia

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2735 views
  • 0 likes
  • 4 in conversation