DATA Step, Macro, Functions and more

Can you stack commands in an 'x' statement in Windows?

Accepted Solution Solved
Reply
Regular Contributor
Posts: 179
Accepted Solution

Can you stack commands in an 'x' statement in Windows?

[ Edited ]

Hi,

 

I would like to be able to do something like this:

 

x 'p:^cd \sites\^spacechk.bat >c:\sites.txt';

 

Assuming the ^ character is a command separator.  Not sure if it is possible in Windows, much less easy.  Anyone done this before?

 

--Ben


Accepted Solutions
Solution
‎10-17-2016 04:34 PM
Super User
Posts: 19,837

Re: Can you stack commands in an 'x' statement in Windows?

Posted in reply to BenConner

You separate commands by & or &&, but each command has to correct. 

 

Test it on your OS first and then use it in SAS.

View solution in original post


All Replies
Solution
‎10-17-2016 04:34 PM
Super User
Posts: 19,837

Re: Can you stack commands in an 'x' statement in Windows?

Posted in reply to BenConner

You separate commands by & or &&, but each command has to correct. 

 

Test it on your OS first and then use it in SAS.

Regular Contributor
Posts: 179

Re: Can you stack commands in an 'x' statement in Windows?

Oh, now that's slick.  Worked perfectly.

 

Thanks!!

 

--Ben

Regular Contributor
Posts: 179

Re: Can you stack commands in an 'x' statement in Windows?

Posted in reply to BenConner

On a related note, is there a way to mask an embedded blank in an argument to a batch file?  By default it will throw off the count of the # of arguments...

 

Thanks!

 

--Ben

Super User
Posts: 19,837

Re: Can you stack commands in an 'x' statement in Windows?

Posted in reply to BenConner

Usually you use quotation marks? You can embded single quotes within double quotes or double quotes within single quotes as necessary.

Regular Contributor
Posts: 179

Re: Can you stack commands in an 'x' statement in Windows?

Doesn't seem to work in passing arguments in a .bat file.  Will Google it and see what I can find.

 

Thanks!

 

--Ben

Super User
Posts: 11,343

Re: Can you stack commands in an 'x' statement in Windows?

Posted in reply to BenConner

You may have to show the content of the batch file.

Regular Contributor
Posts: 179

Re: Can you stack commands in an 'x' statement in Windows?

[ Edited ]

That's certainly not a problem.  I called it runsas.bat:

echo Initiating run for %3.sas
echo 1=%~1
echo 2=%~2
echo 3=%~3
pause
%1
cd %2
copy lock %3.lck
"C:\Program Files\SASHome\SASFoundation\9.4\sas.exe" -sysin "%3.sas" -memsize max
del %3.lck

 

The first 4 lines are for debugging and will go away.  The object was to run it from SAS with the X command.  Argument 1 is the drive letter; argument 2 is the path to the SAS program to be run; argument 3 is the name of the SAS source file w/o a suffix.

 

The file 'lock' is a single character file used as a blocking semaphore.  Or will be when I get this working.

 

Since the path can have embedded spaces in it, this has been causing me grief trying to get it right.

 

--Ben

 

Regular Contributor
Posts: 179

Re: Can you stack commands in an 'x' statement in Windows?

Posted in reply to BenConner

While I wasn't able to find a solution to the original question, I found a way to get (mostly) the same thing done:

 

x " ""C:\Program Files\SASHome\SASFoundation\9.4\sas.exe"" -sysin ""&runpath\test1.sas"" -log ""&runpath\test1.log"" ";

also works nicely for kicking off an external SAS run.  Coupling it with noxwait and noxsync then allows a controlling SAS sheduler to spawn off different SAS runs at will without getting held up waiting for each to complete.  This was the final goal.

 

Thanks!

 

--Ben

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 378 views
  • 0 likes
  • 3 in conversation