Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Condition check in SAS

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Fri Jul 23, 2010 2:48 pm    Post subject: Condition check in SAS
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: 8593
Location: Back in jolly old England

PostPosted: Fri Jul 23, 2010 3:22 pm    Post subject:
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: 2422
Location: Netherlands, Amstelveen

PostPosted: Fri Jul 23, 2010 3:25 pm    Post subject:
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: 1445
Location: Azeroth

PostPosted: Fri Jul 23, 2010 3:27 pm    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Fri Jul 23, 2010 3:35 pm    Post subject:
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: 1445
Location: Azeroth

PostPosted: Fri Jul 23, 2010 4:00 pm    Post subject:
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: 7913
Location: Bellevue, IA

PostPosted: Fri Jul 23, 2010 4:11 pm    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Fri Jul 23, 2010 4:30 pm    Post subject:
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: 2422
Location: Netherlands, Amstelveen

PostPosted: Fri Jul 23, 2010 5:38 pm    Post subject:
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: 1445
Location: Azeroth

PostPosted: Mon Jul 26, 2010 8:11 pm    Post subject:
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: 7913
Location: Bellevue, IA

PostPosted: Mon Jul 26, 2010 8:15 pm    Post subject:
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: 2422
Location: Netherlands, Amstelveen

PostPosted: Mon Jul 26, 2010 8:54 pm    Post subject:
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: 7913
Location: Bellevue, IA

PostPosted: Mon Jul 26, 2010 9:20 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts INCLUDE condition questions van bui DFSORT/ICETOOL 1 Thu Jun 30, 2016 9:52 am
No new posts 2 vsam file compare and update a fiel... ABINAYATHULASI DFSORT/ICETOOL 6 Sun May 29, 2016 11:15 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us