SAS packed decimal field keeps rounding on output

   

  Asked by Anonymous - SAS packed decimal field keeps rounding on output:
This code below shows a sas example of how to stop the output from always rounding in sas when its a packed decimal field you read in on the input.  The key is you just need to use the format statement to tell sas you want this to remain a specific size as the code shows you below.

Assume you read in a packed decimal field like this, it will round the value when you do proc print but this will stop the rounding from occurring.

DATA FILE1;
   INFILE INPUT1;
   INPUT @12  ID   $10.
         @90 NUM1 PD10.4 ;
RUN;

The packed decimal input field "NUM1" will round when you display it later, so use the format option as shown:

DATA FILE1;
   INFILE INPUT1;
   INPUT @12  ID   $10.
         @90 NUM1 PD10.4 ;
FORMAT NUM1 14.4;
RUN;

Anonymous Says:
Note that the format statement can also be used on the sas proc print section.  That would also fix this rounding display issue if you wanted to do it there instead.

Anonymous Says:
Not sure why SAS rounds this but I was about to post the same thing.  The format statement fixes it and it displays on print exactly as expected.

Add your reply below ...


Your Nickname:

Your Reply:

Type the code: