Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SAS - Recognize missing values when reading CSV

Tags:

sas

Given the csv:

Cat,,9
Dog,,10
Egg,,11

And the code:

DATA database ;
INFILE '/path/to/data' dlm=',' missover;
INPUT 
    animal $
    missing $ 
    number 
    ;
RUN;

The output I get is:

animal   missing   number
Cat      9        
Dog      10       
Egg      11

How can I get SAS to recognize the missing value, so that my output table is like the one below?

animal   missing   number
Cat                9        
Dog                10       
Egg                11
like image 869
Fortunato Avatar asked Jun 09 '26 20:06

Fortunato


1 Answers

You just need to include dsd in your infile statement as this signifies that SAS should treat two consecutive commas as a missing value. You can read more information here:

DATA database ;
INFILE '/path/to/data' dlm=',' missover dsd;
INPUT 
    animal $
    missing $ 
    number 
    ;
RUN;
like image 117
Bendy Avatar answered Jun 11 '26 21:06

Bendy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!