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

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

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

@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.

View solution in original post

8 REPLIES 8
Reeza
Super User

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
Obsidian | Level 7
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 .
Kurt_Bremser
Super User

@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.

bmsampath
Obsidian | Level 7

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.

Kurt_Bremser
Super User

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.

bmsampath
Obsidian | Level 7

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

Kurt_Bremser
Super User

@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.

bmsampath
Obsidian | Level 7

Big Thanks. Now it is working after removing amphersand. Thanks,Sampath

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
  • 1196 views
  • 0 likes
  • 3 in conversation