DATA Step, Macro, Functions and more

Does anyone know how to eliminate scientific notation from proc compare list file.

Reply
Contributor
Posts: 43

Does anyone know how to eliminate scientific notation from proc compare list file.

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

Super User
Posts: 10,500

Re: Does anyone know how to eliminate scientific notation from proc compare list file.

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.

Ask a Question
Discussion stats
  • 1 reply
  • 1120 views
  • 0 likes
  • 2 in conversation