Out of memory, how to reduce this program's size

tgsuperspec:
Not sure what you mean..

It consumes RAM a FLASH ROM:

 Serial.println("SD card not present or error opening datalog.txt");

It consumes only FLASH ROM:

 Serial.println(F("SD card not present or error opening datalog.txt"));