Using a temporary file is a pretty good way to go about this sort of thing. Putting log output into a variable is potentially problematic in shell scripting as there is a pretty small limit to the amount of data a variable can hold, and log output can get pretty big - especially when there are problems which you're trying to diagnose... at that time you really don't want to be debugging your shellscript!
Since most modern distros mount /tmp as a ramdisk, there's not really much overhead for something like this:
# set up your variables...
tmp=$(mktemp) || exit 1
ssh $SSH_OPTIONS $USER@$NODES "cd $LOG_DIR; grep -h '$pattern' log.*" > "$tmp"
# now do whatever you like to your log data, for example:
error_count=$(grep -c ERROR "$tmp")
echo "I found $error_count errors for $USER@$NODES"
# don't forget to delete the tmp file
rm -f "$tmp"
*edit* If you really want to do a lot of manipulation of log data in memory, then shell scripting is probably not the best option. A perl, awk or python program might be a better way to go.