SAS OnlineTutorback||next

Try It! Merge the sorted data sets Work.Adsort and Work.Strsort and exclude unmatched observations.

Creating HTML output? Read this first.

  1. Copy the program below and paste it into the Program Editor window (or issue the command copy sashelp.oltutor..source). Then submit the program. In the output, notice that two observations were unmatched in the input data sets and contain missing values for several variables.

data sasuser.merged;
   merge work.adsort
         (rename=(date=AdmitDate))
         work.strsort
         (rename=(date=VisitDate));
   by id;
run;
proc print data=sasuser.merged;
run;

NOTE: Work.Adsort and Work.Strsort were created in a previous practice. If you haven't created these data sets, return to the practice and create them before proceeding here.
  1. Recall the program and add two data set options to create and name variables that indicate whether the Adsort and Strsort data sets, respectively, contributed data to the current observation. Name the variables inad and instr. Also add a statement that checks the IN= values and outputs only those observations that appear in both data sets.

  2. Resubmit the program and view log messages about the DATA step. Scroll through the output. Note that only matched observations now appear in the data set.

    Return here and select Next.

Solution

back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA.
All rights reserved.

Terms of Use & Legal Information | Privacy Statement