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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

8 REPLIES 8
Reeza
Super User

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

 

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

BenConner
Pyrite | Level 9

Oh, now that's slick.  Worked perfectly.

 

Thanks!!

 

--Ben

BenConner
Pyrite | Level 9

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

Reeza
Super User

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

BenConner
Pyrite | Level 9

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

 

Thanks!

 

--Ben

ballardw
Super User

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

BenConner
Pyrite | Level 9

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

 

BenConner
Pyrite | Level 9

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

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 8 replies
  • 1103 views
  • 0 likes
  • 3 in conversation