Note that, to accomplish the match-merge, we have to place the DESCENDING keyword in the BY statement before the subj variable, so that SAS knows that the input data sets ( descdemog and descstatus) are sorted in descending order. The DATA step tells SAS that we want to match-merge the data sets appearing in the MERGE statement ( descdemog and descstatus), by the variable appearing in the BY statement ( subj), and to store the result in a new data set called descpatients. The match-merge again takes place in the third DATA step, in which we see a MERGE statement and a BY statement. The keyword DESCENDING that precedes the subj variable in each SORT procedure tells SAS to sort the subj values in descending order - that is, with the largest subj value appearing first, and the smallest subj value appearing last. The two SORT procedures tell SAS to sort the demog and status data sets by the variable subj, and to store the results, respectively, in data sets called descdemog and descstatus. a match-merge in which the observations in the first data set to be merged matches one or more observations in the second data set to be merged.a match-merge in which the data sets to be merged share, aside from the variable that links the data sets together, at least one common variable name.a match-merge in which the data sets to be merged contain a different number of observations, and each observation in the first data set matches with no more than one observation in the second data set.a match-merge in which the data sets to be merged are sorted by the BY variable in descending order.a match-merge in which the data sets to be merged contain the same number of observations, and each observation in the first data set matches with exactly one observation in the second data set.In increasing order of complexity, the situations are: Throughout the rest of this section, we will look at examples of match-merges under various situations. One thing to keep in mind, though, is you can't match-merge SAS data sets unless they are sorted by the variables appearing in the BY statement. To match-merge, you simply specify the data sets you would like to merge in a MERGE statement, and indicate the variables on which you would like to merge in a BY statement.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |