Hi,
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.
data header;
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>
run;
Try using ABORT RETURN - the documentation is here
Try using ABORT RETURN - the documentation is here
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.
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.
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.