BookmarkSubscribeRSS Feed
zqkal
Obsidian | Level 7

First of all thanks for reading my question.

Here is what I want to do:

I want to know the number of observation changed between two identical datasets for each variable.

I want to create an excel report showing the variable name and the number of differences.

Here is what I’m doing:

I used proc compare to get the number of differences (Ndif). I created a sas datasets using ODS and extract the numbers from the dataset using data step.

Here is the problem:

Proc compare is generating scientific notation for  Number of differences (Ndif) ? 

How can I have proc compare to display the full number.

NOTE: Both datasets have 8 million observation and 500 variables. 

I tried to use merge statement but it wasn’t efficient.

Here is a sample code:

Example: 

ods listing close ;

ods output compsum=outputsum;

proc compare base=work.dsn1 compare=work.dsn2

                                maxprint=(100,500) novalues  listequalvar;

   id loan_key;

run;

ods output close ;

ods listing ;

data outdir.summary;

  set indir.outputsum;

   length Field_Name $40;

   batch=left(compbl(batch));

   if (index(batch, 'NUM') gt 0 or index(batch, 'CHAR') gt 0) and type ne 'h' then

   do;

         if countw(batch, ' ') = 3 or countw(batch, ' ') = 4 then &curr_count. = 0;

         if scan(batch, 2) eq 'NUM'  and countw(batch, ' ') = 7 then &curr_count. = scanq(batch, 5) ;

         if scan(batch, 2) eq 'NUM'  and countw(batch, ' ') = 6 then &curr_count. = scanq(batch, 4);

         if scan(batch, 2) eq 'CHAR' and countw(batch, ' ') = 6 then &curr_count. = scanq(batch, 5);

         if scan(batch, 2) eq 'CHAR' and countw(batch, ' ') = 5 then &curr_count. = scanq(batch, 4);

   output;

   end;

keep Field_Name &curr_count.;

run;

Thanks in advance

1 REPLY 1
ballardw
Super User

In the dataset step you can change the format for the variables. Currently it is likely that the NDIF has a format like best8. Try

format ndif f16.0;

However you may have enough differences that NDIF is actually trying to exceed SAS precision.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 5470 views
  • 0 likes
  • 2 in conversation