BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JereNeal
Fluorite | Level 6

I am trying to create a job in DI Studio that runs an OS command via the X statement.

For troubleshooting purposes, I need access to the return value from the OS, or the output from the execution, or something that would indicate if it is failing and why.

 

For simplicity's sake, suppose I had the following code (in the 'pre-code') tab. 

 

x echo $(date) >>RunLog.txt ;

 

and there was a permissions issue with the output file.

 

How would I obtain error information from the 'x' command?  Or hopefully anything that would have gone to the console or error device.

I realize that control is passing temporarily out of SAS's control, so maybe nothing is possible, but I figured it's worth asking about.

 

Also, the command may need to have quotes around it, but in either case, the job runs successfully (I.E. no error from DI Studio's point of view), but the command was never executed.

I'm on Studio V4.902

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User
Because it does not give you any control over where the outputs from the command go.

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

I never use the X command in production SAS code.

Use a data step with a PIPE.

data _null_;
  infile "x echo $(date) >>RunLog.txt" pipe;
   input;
  put _infile_;
run;
JereNeal
Fluorite | Level 6

Tom,

Thank you for the reply.  As it turns out, because I was unaware that SAS Studio is a different product than SAS DI Studio, I have posted to the wrong forum, but your answer is probably just as applicable for DI Studio.  If you would not use the X command in prod, then perhaps it's a rule I would want to follow as well, so can you let me know why you choose not to use it?

Tom
Super User Tom
Super User
Because it does not give you any control over where the outputs from the command go.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 923 views
  • 0 likes
  • 3 in conversation