How to run batch sas job in unix sas?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












1















I have 5 SAS jobs that I need to run sequentially, one after the other.



I typically type in nohup sas filename1.sas & in the command line to run and manually check for progress every few hours.
If the 1st job is complete and no error, I then type in the 2nd job nohup sas filename2.sas & .



Is there a sas code or unix command I can run them sequentially rather than manually checking progress?



I thought about using %include statement in a master sas file, however I have many loop macros and do if then macros which throw the %include off I believe.



PS. I also need the log and lst file to be printed, typically it's printed for me automatically using the command above.










share|improve this question



















  • 1





    How do you determine if a job has completed properly with no error?

    – Stephen Harris
    Aug 15 '16 at 21:49















1















I have 5 SAS jobs that I need to run sequentially, one after the other.



I typically type in nohup sas filename1.sas & in the command line to run and manually check for progress every few hours.
If the 1st job is complete and no error, I then type in the 2nd job nohup sas filename2.sas & .



Is there a sas code or unix command I can run them sequentially rather than manually checking progress?



I thought about using %include statement in a master sas file, however I have many loop macros and do if then macros which throw the %include off I believe.



PS. I also need the log and lst file to be printed, typically it's printed for me automatically using the command above.










share|improve this question



















  • 1





    How do you determine if a job has completed properly with no error?

    – Stephen Harris
    Aug 15 '16 at 21:49













1












1








1








I have 5 SAS jobs that I need to run sequentially, one after the other.



I typically type in nohup sas filename1.sas & in the command line to run and manually check for progress every few hours.
If the 1st job is complete and no error, I then type in the 2nd job nohup sas filename2.sas & .



Is there a sas code or unix command I can run them sequentially rather than manually checking progress?



I thought about using %include statement in a master sas file, however I have many loop macros and do if then macros which throw the %include off I believe.



PS. I also need the log and lst file to be printed, typically it's printed for me automatically using the command above.










share|improve this question
















I have 5 SAS jobs that I need to run sequentially, one after the other.



I typically type in nohup sas filename1.sas & in the command line to run and manually check for progress every few hours.
If the 1st job is complete and no error, I then type in the 2nd job nohup sas filename2.sas & .



Is there a sas code or unix command I can run them sequentially rather than manually checking progress?



I thought about using %include statement in a master sas file, however I have many loop macros and do if then macros which throw the %include off I believe.



PS. I also need the log and lst file to be printed, typically it's printed for me automatically using the command above.







batch-jobs macro






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 15 '16 at 22:26









Law29

1,0081513




1,0081513










asked Aug 15 '16 at 21:14









SuperKingSuperKing

2615




2615







  • 1





    How do you determine if a job has completed properly with no error?

    – Stephen Harris
    Aug 15 '16 at 21:49












  • 1





    How do you determine if a job has completed properly with no error?

    – Stephen Harris
    Aug 15 '16 at 21:49







1




1





How do you determine if a job has completed properly with no error?

– Stephen Harris
Aug 15 '16 at 21:49





How do you determine if a job has completed properly with no error?

– Stephen Harris
Aug 15 '16 at 21:49










1 Answer
1






active

oldest

votes


















0














there are a couple of ways you can check if you have jobs running. Lets say you ran the command



nohup sas filename1.sas &


you should see something like this in return:



[1] 7539
[mel@server] $ nohup: ignoring input and appending output to `nohup.out'


you can check the existence of process number 7539 using an infinite loop as follows:



PID=$! # this must be run immediately after submitting your job
flag=0
while [ $flag -eq 0 ]
do
sleep 30
ps -ef | grep $PID | grep -v grep >/dev/null
flag=$?
done
echo "process $PID completed or died"


or you can do something in more crude way:



flag=1
while [ $flag -ne 0 ]
do
sleep 30
flag=$(jobs|wc -l)
done
echo "all background jobs have finished or died"


either of these methods will check existence of your background jobs every 30 seconds and completes when there is no job running in the background. First method is my preference.



EDIT (Per comments below):



To run all 5 jobs running one after the other, regardless of success or failure of preceding job, you can do this (note that, code below assumes your sas job filenames are in the format of filename1.sas , filename2.sas , ... , filename5.sas):



>nohup.out
for i in 1 2 3 4 5
do
nohup sas filename$i.sas &
PID=$!
flag=0
while [ $flag -eq 0 ]
do
sleep 30
ps -ef | grep $PID | grep -v grep >/dev/null
flag=$?
done # end of while loop
echo "process $PID completed or died"
mv nohup.out filename$i.log # preserve a separate log file for each job
# if you know the successful and failed exit codes of sas process,
# you can compare the result to those values here. Since you did not
# provide any exit codes, this is left as is.
done # end of for loop





share|improve this answer

























  • I'm actually looking for a method that I can run code 1, and once code 1 its done, I want to run code 2, then once its done, run code 3.

    – SuperKing
    Aug 16 '16 at 1:48












  • Then, you need to know what happens when your job dies or completes with errors, i.e., unsuccessful run. And the difference between a successful and unsuccessful run. Or doesn't it matter if it is successfull or not, you just need to run the next job ?

    – MelBurslan
    Aug 16 '16 at 13:56











  • It does not make too much of a difference, would be nice if I know if a job die but priority is to run the next job

    – SuperKing
    Aug 16 '16 at 19:10











  • Please see the last block under EDIT header for running all 5 jobs in sequence.

    – MelBurslan
    Aug 16 '16 at 19:30










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f303583%2fhow-to-run-batch-sas-job-in-unix-sas%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














there are a couple of ways you can check if you have jobs running. Lets say you ran the command



nohup sas filename1.sas &


you should see something like this in return:



[1] 7539
[mel@server] $ nohup: ignoring input and appending output to `nohup.out'


you can check the existence of process number 7539 using an infinite loop as follows:



PID=$! # this must be run immediately after submitting your job
flag=0
while [ $flag -eq 0 ]
do
sleep 30
ps -ef | grep $PID | grep -v grep >/dev/null
flag=$?
done
echo "process $PID completed or died"


or you can do something in more crude way:



flag=1
while [ $flag -ne 0 ]
do
sleep 30
flag=$(jobs|wc -l)
done
echo "all background jobs have finished or died"


either of these methods will check existence of your background jobs every 30 seconds and completes when there is no job running in the background. First method is my preference.



EDIT (Per comments below):



To run all 5 jobs running one after the other, regardless of success or failure of preceding job, you can do this (note that, code below assumes your sas job filenames are in the format of filename1.sas , filename2.sas , ... , filename5.sas):



>nohup.out
for i in 1 2 3 4 5
do
nohup sas filename$i.sas &
PID=$!
flag=0
while [ $flag -eq 0 ]
do
sleep 30
ps -ef | grep $PID | grep -v grep >/dev/null
flag=$?
done # end of while loop
echo "process $PID completed or died"
mv nohup.out filename$i.log # preserve a separate log file for each job
# if you know the successful and failed exit codes of sas process,
# you can compare the result to those values here. Since you did not
# provide any exit codes, this is left as is.
done # end of for loop





share|improve this answer

























  • I'm actually looking for a method that I can run code 1, and once code 1 its done, I want to run code 2, then once its done, run code 3.

    – SuperKing
    Aug 16 '16 at 1:48












  • Then, you need to know what happens when your job dies or completes with errors, i.e., unsuccessful run. And the difference between a successful and unsuccessful run. Or doesn't it matter if it is successfull or not, you just need to run the next job ?

    – MelBurslan
    Aug 16 '16 at 13:56











  • It does not make too much of a difference, would be nice if I know if a job die but priority is to run the next job

    – SuperKing
    Aug 16 '16 at 19:10











  • Please see the last block under EDIT header for running all 5 jobs in sequence.

    – MelBurslan
    Aug 16 '16 at 19:30















0














there are a couple of ways you can check if you have jobs running. Lets say you ran the command



nohup sas filename1.sas &


you should see something like this in return:



[1] 7539
[mel@server] $ nohup: ignoring input and appending output to `nohup.out'


you can check the existence of process number 7539 using an infinite loop as follows:



PID=$! # this must be run immediately after submitting your job
flag=0
while [ $flag -eq 0 ]
do
sleep 30
ps -ef | grep $PID | grep -v grep >/dev/null
flag=$?
done
echo "process $PID completed or died"


or you can do something in more crude way:



flag=1
while [ $flag -ne 0 ]
do
sleep 30
flag=$(jobs|wc -l)
done
echo "all background jobs have finished or died"


either of these methods will check existence of your background jobs every 30 seconds and completes when there is no job running in the background. First method is my preference.



EDIT (Per comments below):



To run all 5 jobs running one after the other, regardless of success or failure of preceding job, you can do this (note that, code below assumes your sas job filenames are in the format of filename1.sas , filename2.sas , ... , filename5.sas):



>nohup.out
for i in 1 2 3 4 5
do
nohup sas filename$i.sas &
PID=$!
flag=0
while [ $flag -eq 0 ]
do
sleep 30
ps -ef | grep $PID | grep -v grep >/dev/null
flag=$?
done # end of while loop
echo "process $PID completed or died"
mv nohup.out filename$i.log # preserve a separate log file for each job
# if you know the successful and failed exit codes of sas process,
# you can compare the result to those values here. Since you did not
# provide any exit codes, this is left as is.
done # end of for loop





share|improve this answer

























  • I'm actually looking for a method that I can run code 1, and once code 1 its done, I want to run code 2, then once its done, run code 3.

    – SuperKing
    Aug 16 '16 at 1:48












  • Then, you need to know what happens when your job dies or completes with errors, i.e., unsuccessful run. And the difference between a successful and unsuccessful run. Or doesn't it matter if it is successfull or not, you just need to run the next job ?

    – MelBurslan
    Aug 16 '16 at 13:56











  • It does not make too much of a difference, would be nice if I know if a job die but priority is to run the next job

    – SuperKing
    Aug 16 '16 at 19:10











  • Please see the last block under EDIT header for running all 5 jobs in sequence.

    – MelBurslan
    Aug 16 '16 at 19:30













0












0








0







there are a couple of ways you can check if you have jobs running. Lets say you ran the command



nohup sas filename1.sas &


you should see something like this in return:



[1] 7539
[mel@server] $ nohup: ignoring input and appending output to `nohup.out'


you can check the existence of process number 7539 using an infinite loop as follows:



PID=$! # this must be run immediately after submitting your job
flag=0
while [ $flag -eq 0 ]
do
sleep 30
ps -ef | grep $PID | grep -v grep >/dev/null
flag=$?
done
echo "process $PID completed or died"


or you can do something in more crude way:



flag=1
while [ $flag -ne 0 ]
do
sleep 30
flag=$(jobs|wc -l)
done
echo "all background jobs have finished or died"


either of these methods will check existence of your background jobs every 30 seconds and completes when there is no job running in the background. First method is my preference.



EDIT (Per comments below):



To run all 5 jobs running one after the other, regardless of success or failure of preceding job, you can do this (note that, code below assumes your sas job filenames are in the format of filename1.sas , filename2.sas , ... , filename5.sas):



>nohup.out
for i in 1 2 3 4 5
do
nohup sas filename$i.sas &
PID=$!
flag=0
while [ $flag -eq 0 ]
do
sleep 30
ps -ef | grep $PID | grep -v grep >/dev/null
flag=$?
done # end of while loop
echo "process $PID completed or died"
mv nohup.out filename$i.log # preserve a separate log file for each job
# if you know the successful and failed exit codes of sas process,
# you can compare the result to those values here. Since you did not
# provide any exit codes, this is left as is.
done # end of for loop





share|improve this answer















there are a couple of ways you can check if you have jobs running. Lets say you ran the command



nohup sas filename1.sas &


you should see something like this in return:



[1] 7539
[mel@server] $ nohup: ignoring input and appending output to `nohup.out'


you can check the existence of process number 7539 using an infinite loop as follows:



PID=$! # this must be run immediately after submitting your job
flag=0
while [ $flag -eq 0 ]
do
sleep 30
ps -ef | grep $PID | grep -v grep >/dev/null
flag=$?
done
echo "process $PID completed or died"


or you can do something in more crude way:



flag=1
while [ $flag -ne 0 ]
do
sleep 30
flag=$(jobs|wc -l)
done
echo "all background jobs have finished or died"


either of these methods will check existence of your background jobs every 30 seconds and completes when there is no job running in the background. First method is my preference.



EDIT (Per comments below):



To run all 5 jobs running one after the other, regardless of success or failure of preceding job, you can do this (note that, code below assumes your sas job filenames are in the format of filename1.sas , filename2.sas , ... , filename5.sas):



>nohup.out
for i in 1 2 3 4 5
do
nohup sas filename$i.sas &
PID=$!
flag=0
while [ $flag -eq 0 ]
do
sleep 30
ps -ef | grep $PID | grep -v grep >/dev/null
flag=$?
done # end of while loop
echo "process $PID completed or died"
mv nohup.out filename$i.log # preserve a separate log file for each job
# if you know the successful and failed exit codes of sas process,
# you can compare the result to those values here. Since you did not
# provide any exit codes, this is left as is.
done # end of for loop






share|improve this answer














share|improve this answer



share|improve this answer








edited Aug 16 '16 at 19:30

























answered Aug 15 '16 at 21:32









MelBurslanMelBurslan

5,30011533




5,30011533












  • I'm actually looking for a method that I can run code 1, and once code 1 its done, I want to run code 2, then once its done, run code 3.

    – SuperKing
    Aug 16 '16 at 1:48












  • Then, you need to know what happens when your job dies or completes with errors, i.e., unsuccessful run. And the difference between a successful and unsuccessful run. Or doesn't it matter if it is successfull or not, you just need to run the next job ?

    – MelBurslan
    Aug 16 '16 at 13:56











  • It does not make too much of a difference, would be nice if I know if a job die but priority is to run the next job

    – SuperKing
    Aug 16 '16 at 19:10











  • Please see the last block under EDIT header for running all 5 jobs in sequence.

    – MelBurslan
    Aug 16 '16 at 19:30

















  • I'm actually looking for a method that I can run code 1, and once code 1 its done, I want to run code 2, then once its done, run code 3.

    – SuperKing
    Aug 16 '16 at 1:48












  • Then, you need to know what happens when your job dies or completes with errors, i.e., unsuccessful run. And the difference between a successful and unsuccessful run. Or doesn't it matter if it is successfull or not, you just need to run the next job ?

    – MelBurslan
    Aug 16 '16 at 13:56











  • It does not make too much of a difference, would be nice if I know if a job die but priority is to run the next job

    – SuperKing
    Aug 16 '16 at 19:10











  • Please see the last block under EDIT header for running all 5 jobs in sequence.

    – MelBurslan
    Aug 16 '16 at 19:30
















I'm actually looking for a method that I can run code 1, and once code 1 its done, I want to run code 2, then once its done, run code 3.

– SuperKing
Aug 16 '16 at 1:48






I'm actually looking for a method that I can run code 1, and once code 1 its done, I want to run code 2, then once its done, run code 3.

– SuperKing
Aug 16 '16 at 1:48














Then, you need to know what happens when your job dies or completes with errors, i.e., unsuccessful run. And the difference between a successful and unsuccessful run. Or doesn't it matter if it is successfull or not, you just need to run the next job ?

– MelBurslan
Aug 16 '16 at 13:56





Then, you need to know what happens when your job dies or completes with errors, i.e., unsuccessful run. And the difference between a successful and unsuccessful run. Or doesn't it matter if it is successfull or not, you just need to run the next job ?

– MelBurslan
Aug 16 '16 at 13:56













It does not make too much of a difference, would be nice if I know if a job die but priority is to run the next job

– SuperKing
Aug 16 '16 at 19:10





It does not make too much of a difference, would be nice if I know if a job die but priority is to run the next job

– SuperKing
Aug 16 '16 at 19:10













Please see the last block under EDIT header for running all 5 jobs in sequence.

– MelBurslan
Aug 16 '16 at 19:30





Please see the last block under EDIT header for running all 5 jobs in sequence.

– MelBurslan
Aug 16 '16 at 19:30

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f303583%2fhow-to-run-batch-sas-job-in-unix-sas%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay