0
votes

I am new in SAS environment. Maybe this is a stupid question but I cannot figure it out.

LIBNAME CODY '/folders/myfolders/Cody';

data In_Both
Missing_Name(drop = Name); 
merge purchase(in=In_Purch) 
inventory(in=In_Invent);
by Model;
if In_Purch and In_Invent then output In_Both; 
else if In_Invent and not In_Purch then output Missing_Name;
run;

This is the error I receive

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         LIBNAME CODY '/folders/myfolders/Cody';
 NOTE: Libref CODY was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /folders/myfolders/Cody
 74         
 75         data In_Both
 76         Missing_Name(drop = Name);
 77         merge purchase(in=In_Purch)
 78         inventory(in=In_Invent);
 ERROR: File WORK.PURCHASE.DATA does not exist.
 ERROR: File WORK.INVENTORY.DATA does not exist.
 79         by Model;
 80         if In_Purch and In_Invent then output In_Both;
 81         else if In_Invent and not In_Purch then output Missing_Name;
 82         run;

It seems that SAS cannot find the files even though they exists. I'm using SAS university Edition. The code should give me 2 datasets, one with the merged observation and another one with the unmerged observations.

Is there a specific way to load the datasets I need? The two datasets are in format sas7bdat

Thanks everyone for the help!

1

1 Answers

0
votes

Change the merge statement in your code to

merge 
  CODY.purchase(in=In_Purch) 
  CODY.inventory(in=In_Invent)
;

The log is telling you the step is looking for tables in the WORK library, not CODY

Let's look at the original code.

data In_Both Missing_Name(drop = Name); 
  merge 
    purchase(in=In_Purch) 
    inventory(in=In_Invent)
  ;
  by Model;
  if In_Purch and In_Invent then output In_Both; 
  else 
  if In_Invent and not In_Purch then output Missing_Name;
run;

The data set names purchase and inventory in the merge do not include a <libref>.. When a libref is not present, SAS will default to the WORK folder.

The error messages in the log clearly tells you the problem

ERROR: File WORK.PURCHASE.DATA does not exist.
ERROR: File WORK.INVENTORY.DATA does not exist.

You can see the step was looking for WORK.PURCHASE and WORK.INVENTORY and did not find them (because they are in the CODY library)

Change the data sets being merged to include the appropriate library, thus you want CODY.purchase and CODY.inventory