07-24-2017 03:44 AM
I am executing my SAS pgms in unix environment, so executes the .sas pgms in shl.
Now i have a requirement to break a datastep on a particular condition & return a code to shl, so that based on the return code shl will call a sql loader which loads data to oracle table.
infile "<path>/data.dat" dlm="|";
input recds : $2.
id : 18.
name : $30.
chk_flg : $1.;
if(chk_flg) = 'Y';
then <the pgm needs to break with a return code>
07-24-2017 04:19 AM
Personally I find the whole breaking out of programs to be not a good methodology. Code should run fully and then return its final value and outputs at all times.
A question for you, which jumped to mind with the above in mind, I am sure (and its been years since I used it) Unix has string find utilities and such like, so why do you need to read the file into SAS, check for a string, and then jump back to the operating system. Can all this not be done directly in the OS scripting? Even better would be to get a file which is directly usable rather than finding strings. It just seems to be using SAS for the sake of using it.
07-24-2017 04:36 AM
Ok so to answer to your 2nd part, we have a process in place which already uses SAS pgm & run it to completion. The SAS pgm checks few columns(its a validation of data pgm). Now the there is a new requirement which is the file will be submitted at the same path(if the file arrives at the path, the already existing pgm triggers), same file name, only addition is an extra column in header. If we read that SAS dont have to do anything. Hope this makes sense.
07-24-2017 05:02 AM
Given that you have UNIX, I'd solve that with the cut and grep utilities directly from the shell:
if cut -f3 -d'|' filename|grep Y>/dev/null then #execute as wanted else #put message fi
Need further help from the community? Please ask a new question.