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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisBrooks
Ammonite | Level 13

Try using ABORT RETURN - the documentation is here

View solution in original post

4 REPLIES 4
ChrisBrooks
Ammonite | Level 13

Try using ABORT RETURN - the documentation is here

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

GunnerEP
Obsidian | Level 7

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.

Kurt_Bremser
Super User

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

 

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
  • 4 replies
  • 854 views
  • 1 like
  • 4 in conversation