Page 1 of 1

SAS program for comparing files in JCL

PostPosted: Sat Dec 19, 2009 12:31 pm
by koti_aug26
Could anybody please help me to get a SAS program for the following requirement,

The requirement is to compare two files and generate a report. Both the files have same LRECL.

//STEP2 EXEC SASPROD
//SARFILE DD DSN=INFILE1,DISP=SHR
//SARFILE1 DD DSN=INFILE2,DISP=SHR
//RESULT DD DSN=RESFILE,DISP=SHR
//SYSIN DD *
DATA SARPRINT;
INFILE SARFILE;
INFILE SARFILE1;
PROC COMPARE BASE=SARFILE COMP=SARFILE1 OUT=RESULT OUTNOEQUAL;RUN;
/*
//*

If we use above code. We got few errors.

ERROR: File WORK.SARFILE.DATA does not exist.
ERROR: File WORK.SARFILE1.DATA does not exist.

Kindly let me know if any clarification needed.
_________________
Thanks,
Koteswararao

Re: SAS program for comparing files in JCL

PostPosted: Sat Dec 19, 2009 3:16 pm
by salltm
please check the PROC.SASPROD MAYBE There are some files missing in you PROC.

Re: SAS program for comparing files in JCL

PostPosted: Sat Dec 19, 2009 5:48 pm
by expat
salltm wrote:please check the PROC.SASPROD MAYBE There are some files missing in you PROC.

HUH .................... the errors are coding errors.

How can you read from the WORK file when you have not put anything in there

Re: SAS program for comparing files in JCL

PostPosted: Sat Dec 19, 2009 8:41 pm
by Robert Sample
DATA SARPRINT;
INFILE SARFILE;
INFILE SARFILE1;
PROC COMPARE BASE=SARFILE COMP=SARFILE1 OUT=RESULT OUTNOEQUAL;RUN;
This is code from someone who has never used SAS, I would bet. Points about it are:
1. You only create one SAS dataset, which is SARPRINT, yet you are attempting to compare two SAS datasets (SARFILE and SARFILE1), neither of which you have created.
2. Assigning an INFILE in SAS tells SAS nothing but which DD name your input statements are coming from.
3. You have NO INPUT statements, so you are reading no data, so there's not going to be anything in SARPRINT anyway.

The normal processing for a SAS program is:
DATA A;
INFILE SARFILE LENGTH=RL;
INPUT @;
RECLEN = RL;
INPUT @1 DATALINE $VARYING. RECLEN;
which gives you two output variables in the SAS dataset WORK.A -- RECLEN which has the length of each record, and DATALINE which contains the actual data lines read from SARFILE.