BookmarkSubscribeRSS Feed
nickb
Calcite | Level 5

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          
                                                           
************************************************************************************************************************************
                                       

2 REPLIES 2
ballardw
Super User

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;

Tom
Super User Tom
Super User

You might try informat like BZ

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1314 views
  • 0 likes
  • 3 in conversation