BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
aarony
Obsidian | Level 7

hi, thank you in advance for your kind attention.

i have 2 variables: COMPANYID and YEAR

COMPANYID is between 1-100. YEAR can be anywhere between 1950-2013

I want to keep the COMPANYIDs that have more than 10 years within them.

for example:

companyID 1 may have year 1950, 1951 only. i want to drop companyID 1 completely because i only see 2 years and my threshold is 10.

Can you provide me your guidance?

thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Do the years need to be consecutive, or do any 10 years count?

proc sql;

create table want as

select companyid, year, count(*) as count_years

from have

group by companyid

having count(year)>10;

quit;

View solution in original post

3 REPLIES 3
Reeza
Super User

Do the years need to be consecutive, or do any 10 years count?

proc sql;

create table want as

select companyid, year, count(*) as count_years

from have

group by companyid

having count(year)>10;

quit;

aarony
Obsidian | Level 7

thank you for your reply reeza.

what if i want them to fall in a specific time period? ie: 1950-1960? thank you much!

Reeza
Super User

Add in a where clause, 1950 to 1960 is an 11 year period though.

proc sql;

create table want as

select companyid, year, count(*) as count_years

from have

where year between 1950 and 1960

group by companyid

having count(year)>10;

quit;

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
  • 3 replies
  • 1450 views
  • 3 likes
  • 2 in conversation