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

Hi everyone,

I want to create a subset from a dataset. Suppose I have a table like below. What I want to do is keeping all those observations with the same value of Class_ID as what student 1111 has. In this case, I want to create a subset of all observations that the values of their class_ID are equal to 22 or 33.

Student_IDClass_IDScore
111122A
111133A
252022A
252044A
514833A
514866A
625155A

I appreciate any suggestion.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

This won't scale to larger data, you need to be more explicit to what your problem is.

proc sql;

create table want as

select *

from have

where class_id in (select class_id from have where student_id = '1111');

quit;

View solution in original post

4 REPLIES 4
ballardw
Super User

data want;

     set have;

     where Class_id in (22,23);

run;

If Class_id is character then use ('22','23')

m1986MM
Obsidian | Level 7

Actually the dataset is very large. So I can't easily find all values, like 22 or 33. I'm looking for an algorithm that can find all the values belonging to a certain student_ID, and then keep those observations that have the same value.

Reeza
Super User

This won't scale to larger data, you need to be more explicit to what your problem is.

proc sql;

create table want as

select *

from have

where class_id in (select class_id from have where student_id = '1111');

quit;

SelsonMuniappen
Calcite | Level 5

Without further detail about what you are trying to do, my best suggestion would be the same as Reeza, assuming that for every case you know which student_id has the values you are looking for.

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
  • 779 views
  • 0 likes
  • 4 in conversation