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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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