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;

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