Suppose you have a table of part numbers and descriptions in a SAS data set called PARTS. (Assume this data set is already sorted by PART_NO.)You want to read a part number from a data set called INVOICE and add the variable PARTNAME from the PARTS data set to your INVOICE data set. First, here are the two data sets: You can use a MERGE statement to perform the lookup as follows:
ExamplePROC SORT DATA=INVOICE;
Output from the PRINT procedure is shown next:
Output From Example-Simple Table Lookup (Method 1 - Merging)
This program merges the two SAS data sets,PARTS and INVOICE,using the variable PART_NO as the BY variable.Notice that we first sort the INVOICE data set by PART_NO since it is necessary that both data sets be sorted by the same variable.
The PARTS data set was previously sorted,and there is no sense in wasting CPU cycles in sorting it again.(Remember that in SAS System Releases 6.07 and higher,a sort flag is set when a data set is sorted, and a redundant SORT procedure will not be executed.)
The IN= option assures you that only invoiced items (those in the INVOICE data set)will be kept.(See Chapter 3,"SET, MERGE,and UPDATE,"for a more detailed explanation of the MERGE
statement.) To denote the case where a PART_NO value in the INVOICE data set is not in the PARTS data set, you substitute the term NOT ENTERED for your missing value.
SAS Programming Related Tutorials
|SASS (Syntactically Awesome Style sheets) Tutorial||R Programming language Tutorial|
SAS Programming Related Interview Questions
|Logistics Interview Questions||SAS Programming,SQL server Interview Questions|
|Clinical SAS Interview Questions||SASS (Syntactically Awesome Style sheets) Interview Questions|
|SQL Server Analysis Services (SSAS) Interview Questions||R Programming language Interview Questions|
|SAS DI Interview Questions||Advanced SAS Interview Questions|
|Base Sas Interview Questions||SAS Macro Interview Questions|
|Clinical Data Management Interview Questions|
Sas Programming Tutorial
Input And Infile
Set, Merge, And Update
Table Lookup Tools
Proc Means And Proc Uimivariate
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.