DATA Step, Macro, Functions and more

How to see UNIX stderr / return code when using PIPE commands

Reply
Contributor
Posts: 55

How to see UNIX stderr / return code when using PIPE commands

I'm executing UNIX commands using PIPE functionality in SAS. The problem is handling exceptions. If the UNIX server issues an error (stderr) output from the unix command in the pipe, how do I know. The code I inherited just returns nothing when a unix error occurs.

Does SAS have a return code for that similar to SAS/ACCESS for a RDBMS?
Respected Advisor
Posts: 3,777

Re: How to see UNIX stderr / return code when using PIPE commands

Use redirection to send STDERR to STDOUT.

cmd args 2>&1

The syntax may be wrong you will need to check.

Then in your data step read any lines returned when the command is executed and proceed as needed.

By default any STDERR output from commands executed with PIPE should be showing up in the SASLOG.
Contributor
Posts: 55

Re: How to see UNIX stderr / return code when using PIPE commands

after digging through the doc for a while I finally found the automatic macro variable &syscc. That will at least gave an indicator to switch to error handling logic like reading the stderr output like you mentioned.
Ask a Question
Discussion stats
  • 2 replies
  • 331 views
  • 0 likes
  • 2 in conversation