Help using Base SAS procedures

file input

Reply
Contributor
Posts: 65

file input

I am working on reading in a file that has money values in the columns and if they are missing, they need to be $0.  I know the position of where the values are but don't know how to handle the missing values.  When I copied a snippet of the file the values got shifted but the file is column aligned.


                                                                                                XMITTAL            TUITION           ACCOUNT        BOOK           DISBURSEMENT       BOOK CHGS TO
    NAME                                                 SSN           TERM       DATE              & FEES                 REFUND         CHGS            TOTAL                  CARD
==========================  ===========  =====   ===========  ============  ===========  ===========  =============  ============
Aeva, Gua Z                                                           12/WI      01/18/12             723.20                 936.67            190.13                  1850.00                50.00
                                                                            12/SP      04/10/12             703.20                1053.98             92.82                  1850.00                60.00
                                                          
************************************************************************************************************************************
goofy                                                                  11/FA      09/16/11               433.60                 491.40                                          925.00          
                                                                            12/WI    01/18/12             295.00                 168.00                                          463.00          
                                                           
************************************************************************************************************************************
daffy                                                                    11/SU      07/16/11             602.20                 575.38                 210.42             1388.00               100.00
                                                                            11/FA      09/16/11             654.40                 270.30                 925.30             1850.00               100.00
                                                                            12/WI      01/18/12             822.40                 627.73                 399.87             1850.00               100.00
                                                                            12/SP      04/03/12             462.00                                           462.00          
                                                           
************************************************************************************************************************************
                                       

Super User
Posts: 10,460

Re: file input

There are many possible approaches. One is to create a custom INVALUE format for those variables that will assign 0 to the blank or missing or how ever it appears in your data.

Another would be to use an array in a data step. If you are reading the data using input in a data step then add code similar to this:

Array vals list your variable names here;

do i = 1 to dim vals;

     if vals=. then vals=0;

end;

drop i;

Super User
Super User
Posts: 6,495

Re: file input

You might try informat like BZ

Ask a Question
Discussion stats
  • 2 replies
  • 199 views
  • 0 likes
  • 3 in conversation