Here is an example of such a query done via SAS’s PROC SQL using files ONE and TWO (see ABOVE) as input. SQL was designed to query (extract data and create a report from) a relational database. The next Exhibit shows the equivalent words used in different settings. To start with, it employs separate terminology to describe a file. SQL is different from regular SAS in several respects. Namely, the rest starts with an introduction to SQL. (More information about match-merge can be found in the first three references in the Bibliography.)Įxplore SQL and compare it with match-merge. Up until now this paper briefly toured the match-merge world. The Venn diagram allows you to see all the possible sets and sub-sets that you can create via a match-merge of two data sets. ![]() Area C contains ID values that exist only in data set TWO. values that exist in file ONE but do not exist in file TWO).Īrea B contains the ID values that exist in both files. Each ID value falls into one of three areas:Īrea A contains the ID values that are unique to file ONE (i.e. The contents of the circles are the different values of the ID’s (key variables) in each data set. The circle on the right represents data set TWO. The circle on the left represents data set ONE. Now consider the following code which uses the same two input files as above, but has seven different output files.ĭATA ONEs TWOs inBOTH NOmatch1 NOmatch2 allRECS NOmatch Īnother means of examining the match-merge is through a Venn diagram. Observe that the records A05 (file ONE) and A04 (file TWO) did not have a matching record, yet their information was included in the merged data set.Įxhibit 2 shows the default match-merge. Note that in this merge every record from both input files exists in the output file. NOTE: The data set WORK.OUT has 5 observations and 4 variables. NOTE: There were 4 observations read from the data set WORK.TWO. NOTE: There were 4 observations read from the data set WORK.ONE. NOTE: The data set WORK.TWO has 4 observations and 3 variables. NOTE: DATA statement used (Total process time): NOTE: The data set WORK.ONE has 4 observations and 2 variables. ![]() Here is how the above two input files are match-merged in SAS. The information in the matched records is combined to form one output record. A match-merge in SAS means that records from the one file will be matched up with the records of the second file that have the same ID. The records in both files are sorted by ID. ![]() These two files have a common key field called ID. Consider the following two input files, as an example. Of course, sorted means that the input files have a common key and that the records in each file are ordered according to the key field(s). All of them talk about taking two or more sorted input files and combining them into one output file.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |