Skip to content

Instantly share code, notes, and snippets.

@afeld
Last active March 28, 2019 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afeld/81412d944aa427953c46a362b794b7be to your computer and use it in GitHub Desktop.
Save afeld/81412d944aa427953c46a362b794b7be to your computer and use it in GitHub Desktop.
run SAS script from UNIX command line

To use, put the script in a file on the machine you want to run SAS, then make it executable.

chmod +x run_sas.sh

After that, you can use it to run SAS scripts:

./run_sas.sh myscript.sas

This will execute the code, then output the results in your terminal.

#!/bin/bash
set -x
SCRIPT="$1"
BASE="$(basename $SCRIPT .sas)"
LST="${BASE}.lst"
LOG="${BASE}.log"
# cleanup
rm "$LOG" "$LST"
if sasu8 -nodms -terminal "$SCRIPT"; then
# success
less "$LST" "$LOG"
else
# failed
cat $LOG
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment