Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 1532
Location: Chennai

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: 8619
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: 2445
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: 1532
Location: Chennai

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: 8619
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: 1532
Location: Chennai

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: 8200
Location: East Dubuque, Illinois, USA

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: 8619
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: 2445
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: 1532
Location: Chennai

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: 8200
Location: East Dubuque, Illinois, USA

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: 2445
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: 8200
Location: East Dubuque, Illinois, USA

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 BUILD OUTFIL based on condition other... balaji81_k DFSORT/ICETOOL 13 Fri Sep 08, 2017 11:06 pm
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm
This topic is locked: you cannot edit posts or make replies. Need help on If condition continuatio... ashok_uddaraju CLIST & REXX 4 Fri May 19, 2017 8:55 am
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us