Hi All,
I have the following shell script to run the job.
cd ${PROJ_ENV}/data/batchout
. ${PROJ_ENV}/data/batchout/exec_sas_di.sh STP_Report_TEST1 &
. ${PROJ_ENV}/data/batchout/exec_sas_di.sh STP_Report_TEST2 &
In the first program, I am creating a dataset(DOC_TAB) in SASTAB library.(SASTAB.DOC_TAB).
In the second program, when I am checking whether dataset is exist or not using EXIST fn( tried both EXIST or OPEN function), it always returns FALSE during very first run of the job.
From the second run onwards, this checking of dataset returns TRUE.
Please let me know why the second program is not detecting the dataset(Permanent dataset) created in first program.
Thanks in advance.
Thanks,
Sampath
@bmsampath wrote:
I dont have much knowledge in UNIX. I accept whatever you are saying is correct. Could you please tell me how to run the code one by one to avoid this issue ..First TEST1 then TEST2.
Can you give some details abt how to change the unix shell script?
Thanks,Sampath
Just remove the ampersands. Then the script has to wait for the first program to finish before it can start the second.
You need to post some code.
To debug try accessing data in first program and see the error message. It may give you more clues.
@bmsampath wrote:
If I check the dataset in first program, exist returns TRUE. But in second program, exist function returns FALSE. This happens only in batch mode. that too during the first run of the job in all dev, si and prod environment. THIS IS PERMANENT DATASET STORED IN A LIBRARY. Still if you want some more details , I am ready to give .
You are not consistent. From your post:
--
In the first program, I am creating a dataset(DOC_TAB) in SASTAB library.(SASTAB.DOC_TAB).
In the second program, when I am checking whether dataset is exist or not using EXIST fn( tried both EXIST or OPEN function), it always returns FALSE during very first run of the job.
--
So you were NOT checking for the dataset in your first program, you were CREATING it. Since both programs run in parallel, the second program can't detect the dataset until the script has run at least once.
I tried to check the dataset in first program just for debugging purpose.
Actually I am doing the checking in the second program only.
First program creates dataset. Second program is checking the dataset and doing something if it is true.
Very simple. By using the ampersand at the end of a command, you let that run in the background, and control is immediately handed back to the script, which starts the second command; so both SAS programs run concurrently, and the second program starts before the first program had a chance to write the dataset.
I dont have much knowledge in UNIX. I accept whatever you are saying is correct. Could you please tell me how to run the code one by one to avoid this issue ..First TEST1 then TEST2.
Can you give some details abt how to change the unix shell script?
Thanks,Sampath
@bmsampath wrote:
I dont have much knowledge in UNIX. I accept whatever you are saying is correct. Could you please tell me how to run the code one by one to avoid this issue ..First TEST1 then TEST2.
Can you give some details abt how to change the unix shell script?
Thanks,Sampath
Just remove the ampersands. Then the script has to wait for the first program to finish before it can start the second.
Big Thanks. Now it is working after removing amphersand. Thanks,Sampath
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.