When PROC DATASETS assigns the w.d format to a variable, the Fw.d format, which is an alias of w.d, is assigned instead. The output from PROC CONTENTS confirms that the Fw.d format has been assigned. The COMPARE procedure does not consider the Fw.d and w.d formats to be the same. Therefore, PROC COMPARE shows data set attributes as different because of the difference in the format names.
In the code below, variable X in data set A is assigned a format of 5. which is changed to 12.2 with PROC DATASETS. The format is changed to F12.2 and confirmed by viewing the output from PROC CONTENTS that follows the code. A new data set, B, is created with the same attributes as data set A, and PROC COMPARE compares the two. PROC COMPARE shows their attributes as different because of the format name differences since one is F12.2 and the other is 12.2.
If you would prefer to assign the w.d format instead of the Fw.d format, use a FORMAT statement in a DATA step instead of using PROC DATASETS.
/* Format of 5. is assigned to variable X */
data a;
x=100;
format x 5.;
run;
/* Modify the format for X to 12.2 */
proc datasets;
modify a;
format x 12.2;
run;
/* Verify that the F12.2 format is assigned */
proc contents;
run;
/* Create a data set with matching column attributes of data set A */
data b;
x=100;
format x 12.2;
run;
/* Compare data sets A and B */
proc compare base=a compare=b;
run;
The output from the above code is as follows:
The CONTENTS Procedure
Data Set Name WORK.A Observations 1
Member Type DATA Variables 1
Engine V9 Indexes 0
Created 06/27/2018 11:57:18 Observation Length 8
Last Modified 06/27/2018 11:57:18 Deleted Observations 0
Protection Compressed NO
Data Set Type Sorted NO
Label
Data Representation WINDOWS_64
Encoding wlatin1 Western (Windows)
Engine/Host Dependent Information Data Set Page Size 65536 Number of Data Set Pages 2 First Data Page 1 Max Obs per Page 8063 Obs in First Data Page 1 Number of Data Set Repairs 0 ExtendObsCounter YES Filename C:\Users\saskcw\AppData\Local\Temp\SAS Temporary Files\_TD11048_d10a547_\a.sas7bdat Release Created 9.0401M5 Host Created X64_10PRO Owner Name CARYNT\saskcw File Size 192KB File Size (bytes) 196608 Alphabetic List of Variables and Attributes # Variable Type Len Format 1 x Num 8 F12.2
The COMPARE Procedure Comparison of WORK.A with WORK.B (Method=EXACT) Data Set Summary Dataset Created Modified NVar NObs WORK.A 27JUN18:11:57:18 27JUN18:11:57:18 1 1 WORK.B 27JUN18:11:57:19 27JUN18:11:57:19 1 1 Variables Summary Number of Variables in Common: 1. Number of Variables with Differing Attributes: 1. Listing of Common Variables with Differing Attributes Variable Dataset Type Length Format x WORK.A Num 8 F12.2 WORK.B Num 8 12.2 Observation Summary Observation Base Compare First Obs 1 1 Last Obs 1 1 Number of Observations in Common: 1. Total Number of Observations Read from WORK.A: 1. Total Number of Observations Read from WORK.B: 1. Number of Observations with Some Compared Variables Unequal: 0. Number of Observations with All Compared Variables Equal: 1. NOTE: No unequal values were found. All values compared are exactly equal.