![]() The resulting subset has 288 observations. To do this, we can use the DELETE keyword to remove observations where Rank = 1, which is the indicator value for freshman. Let's create a subset of the sample data that doesn't contain any freshmen students. Example - Delete cases with a specific value The inclusion or exclusion criteria appear after the IF statement. ![]() The "disqualifying" values you specify are called the exclusion criteria. DATA New-Dataset-Name (OPTIONS) Ĭreating 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 criteria for keeping an observation is called the inclusion criteria. Inclusion and exclusion criteria are both statements of conditional logic that are based on one or more variables, and one or more values of those variables.Ĭreating 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. Subsets can be created using either inclusion or exclusion criteria. For instructions on how to drop or keep variables from a dataset, see our Data Step tutorial. ![]() Note: A related task is to select a subset of variables (columns) from a dataset. The difference between the two processes is in how the cases are selected. Both processes create new datasets by pulling information out of an existing dataset based on certain criteria. When splitting a dataset, you will have two or more datasets as a result.īoth subsetting and splitting are performed within a data step, and both make use of conditional logic. When subsetting a dataset, you will only have a single new dataset as a result.Ī split acts as a partition of a dataset: it separates the cases in a dataset into two or more new datasets. You can also think of this as "filtering" a dataset so that only some cases are included. In this tutorial, we use the following terms to refer to these two tasks:Ī subset is selection of cases taken from a dataset that match certain criteria. But if there are some 1's, then it is the first value=1 date.When preparing data for analysis, you may need to "filter out" cases (rows) from your dataset, or you may need to divide a dataset into separate pieces. If there are no 1's, then the _cutoff_date is the first value=0 date. If first.category then _cutoff_date=date Set have (where=(value=1) in=firstpass) have (in=secondpass) If you want to keep them all, then the following program will do: If you want to delete them all, then above program works. what do you want to do if a given sub/category has only zeroes? You haven't answer question (or my comment above). In such a case, the program above will drop all obs for that sub/category. What you haven't explained is what you want to do if a given sub/category has no observations with value^=0. So assume data sorted by sub/category/date. This assumes that data are already sorted by sub/category (and presumably you require the data to be sorted by date within each sub/category). If first.category=1 then _n_of_ones=value ![]() You apparently want to delete "leading zeroes" for each sub/category combination.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |