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

I have a 3rd party tool that can export data into any format I want.  I'm trying to use the x command statement to execute this process.  The issue i'm having is that the data set is part of my sas session and does not exist on the local computer.  Can I pass this data set to this process through x command or do I have to save off the data set then access the data through the x command statement?

example code:

options noxwait ;

x 'C:\PROGRA~1\DataTrans\dt.exe work.temp  c:\temp\temp.xlsx';

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

If I understand your question then no.  The X command will run on the computer that SAS is running on.  So it can only call programs that are on that computer.  Now if this conversion program is on the computer which is running SAS then the X command will be able to run it.  You will just need to specify the filenames properly.

I find it best to quote filenames in Windows commands to make sure it doesn't get confused by embedded spaces in file or directory names.

I find it best to use DATA _NULL_ and PIPE to execute commands instead of using the X command.  That way the program can pull any error messages and save them in the SAS log instead of having them appear on some terminal window or disappear completely.

data _null_;

  length cmd $400 ;

  cmd=quote(catx(' '

       ,quote("C:\PROGRA~1\DataTrans\dt.exe")

       ,quote(catx('\',pathname('work'),'temp.sas7bdat'))

       ,quote("c:\temp\temp.xlsx")

      ))

  ;

  infile x pipe filevar=cmd end=eof;

  input ;

  put _infile_;

run;


View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

If I understand your question then no.  The X command will run on the computer that SAS is running on.  So it can only call programs that are on that computer.  Now if this conversion program is on the computer which is running SAS then the X command will be able to run it.  You will just need to specify the filenames properly.

I find it best to quote filenames in Windows commands to make sure it doesn't get confused by embedded spaces in file or directory names.

I find it best to use DATA _NULL_ and PIPE to execute commands instead of using the X command.  That way the program can pull any error messages and save them in the SAS log instead of having them appear on some terminal window or disappear completely.

data _null_;

  length cmd $400 ;

  cmd=quote(catx(' '

       ,quote("C:\PROGRA~1\DataTrans\dt.exe")

       ,quote(catx('\',pathname('work'),'temp.sas7bdat'))

       ,quote("c:\temp\temp.xlsx")

      ))

  ;

  infile x pipe filevar=cmd end=eof;

  input ;

  put _infile_;

run;


jerry898969
Pyrite | Level 9

Thank you so much Tom. Using pathname function on the work library and pointing to the data file was exactly what I needed.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 752 views
  • 1 like
  • 2 in conversation