Custom module to alter display value of field
The example you're using in the hook_page_alter() docs isn't a valid example but a demonstration. The problem here is the variable $nid isn't defined in your hook invocation. The expression:

$page['content']['system_main']['nodes'][$nid]['body']


isn't valid. $page['content']['system_main']['nodes'] contains an associated array of nid/node data. 

This can be one or many nodes depending on the context (e.g. front page vs. a node page). You'll need build your logic accordingly (e.g. $nid = reset($page['content']['system_main']['nodes']) to retrieve the specific node that you want then make the altercation as you need it.