IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Condition check in SAS


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1744
Location: Tirupur, India

PostPosted: Fri Jul 23, 2010 2:48 pm
Reply with quote

Hi,


Could you please let me know if there is an option or statement in SAS to check conditions similar to LIKE operator in where statement.

Example:

Code:
data A;
set B;
where dsn like '%abcd';
or
where dsn like "__abcd';



Is there a similar statement that can be used in a IF condition for checking condition as shown below,

Code:
IF DSN = '%abcd' then  account = 'good';
IF DSN = "__abcd' then account = 'good';


I am not sure if PROC format can be used for this. Can it be used?

Thanks & Regards,
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Fri Jul 23, 2010 3:22 pm
Reply with quote

What about the INDEX function, would that help.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Fri Jul 23, 2010 3:25 pm
Reply with quote

Only if you can substitute ranges for your LIKE values.


PROC FORMAT;
VALUE DSNFMT
'rangea'-'rangeb' = 'good'
'rangec'-'ranged' = 'good';
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1744
Location: Tirupur, India

PostPosted: Fri Jul 23, 2010 3:27 pm
Reply with quote

Hi,

Thanks for the reply,
The condition checks require checking of dataset names with strings at specific position, so index was not adequate.

Example, there are 3000 checks like, icon_sad.gif

$AB.ABC_.CA7%
$AB.____.SMFABC_.%._C

Regards,
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Fri Jul 23, 2010 3:35 pm
Reply with quote

So what are you trying to achieve and maybe we can help in a more roundabout fashion icon_biggrin.gif

Lots of detail please.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1744
Location: Tirupur, India

PostPosted: Fri Jul 23, 2010 4:00 pm
Reply with quote

Its quite complex and I am not sure if I can share the in depth details due to security and other formalities.

We are using a CA product that is based on SAS to classify datasets to specific groups.
The product accepts only SAS code "IF conditions" or other statements that can be used inside a data step as PARM or SYSIN for classification.

so I believe there is no alternate way other than SAS IF statements or SAS statements that are used inside a DATA step .

Thanks,
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Fri Jul 23, 2010 4:11 pm
Reply with quote

You might try a quick test to see if the PRXPARSE function is available in your version of SAS. If so, you have access to Perl regular expressions and much becomes possible.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Fri Jul 23, 2010 4:30 pm
Reply with quote

Have you had a look at PROC SQL which supports the LIKE parameter.

Sorry, should have suggested that earlier, but as my client pays the bill his workload gets priority icon_lol.gif
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Fri Jul 23, 2010 5:38 pm
Reply with quote

Robert Sample wrote:
You might try a quick test to see if the PRXPARSE function is available in your version of SAS. If so, you have access to Perl regular expressions and much becomes possible.


I think you need PRXMATCH too.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1744
Location: Tirupur, India

PostPosted: Mon Jul 26, 2010 8:11 pm
Reply with quote

Hi,
Thanks everyone for sharing your knowledge.
As suggested above, PRXMATCH did the trick icon_biggrin.gif

equivalent statement of
Code:
IF DSN = '$AB.ABC_.CA7%'  then  flag = 'GOOD';

is
Code:
IF prxmatch("/\$AB.ABC[\D.|\d.]{1}.\CA7[\D.|\d.]{0,20}/",DSN) then  flag = 'GOOD';


I have not heard of PERL earlier and thought they were shiny thingies under the sea, but this PERL is interesting icon_smile.gif to learn

Thanks,
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Mon Jul 26, 2010 8:15 pm
Reply with quote

Good catch, Peter!

Glad to hear your problem is resolved, Vasanth. Perl is worth knowing -- even though it's probably the most dangerous programming language I've run across so far.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Mon Jul 26, 2010 8:54 pm
Reply with quote

Quote:

even though it's probably the most dangerous programming language I've run across so far.


Finding dirty words? icon_eek.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Mon Jul 26, 2010 9:20 pm
Reply with quote

Perl variables are:
1. allowed to be very long
2. case-sensitive ($ABC and $abc are two different variables)
3. defined upon first reference so typos cause extra variables
4. the first character determines whether it is string, array, or hash
5. scope depends upon how the variable is defined and used

So there is much potential for mayhem, chaos, and extraneous side-effects!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Add condition to a FINDREP SORT card DFSORT/ICETOOL 4
No new posts To Omit records based n SORT condition DFSORT/ICETOOL 6
No new posts Using Multiple IFTHEN and WHEN condit... SYNCSORT 12
No new posts Check if CICS is online in JCL CICS 10
No new posts SCOPE PENDING option -check data DB2 2
Search our Forums:

Back to Top