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-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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