Reply To: SAS Subsetting & Filtering Trick questions for Interview

#49356
rlochan2021
Keymaster

Creating a subset that contains only records with a certain value: In this case, your subset will keep the records that meet the criteria you specify. The criteria for keeping an observation is called the inclusion criteria.

DATA New-Dataset-Name (OPTIONS);
SET Old-Dataset-Name (OPTIONS);
IF (insert conditions) THEN OUTPUT;
RUN;
Creating a subset that contains only records without a certain value: In this case, your subset will be all of the cases that remain after dropping observations with “disqualifying” values. The “disqualifying” values you specify are called the exclusion criteria.

DATA New-Dataset-Name (OPTIONS);
SET Old-Dataset-Name (OPTIONS);
IF (insert conditions) THEN DELETE;
RUN;

source- https://libguides.library.kent.edu/SAS/SubsetData