LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2006, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 5 Sep 2006 14:00:20 +0000
Reply-To:     toby dunn <tobydunn@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         toby dunn <tobydunn@HOTMAIL.COM>
Subject:      Re: SELECT - Unsatisfied WHEN clause and no OTHERWISE clause
Comments: To: pstloui@DOT.STATE.TX.US
In-Reply-To:  <200609051324.k85AkdhO024425@mailgw.cc.uga.edu>
Content-Type: text/plain; format=flowed

Switch it too a format and you wont need the otherwise clause, however it is considered good form, mainly bacuase what would happen if you reran the code with new data and you didnt have one of your year boundaries. You the programmer may never know that you had data going beyond 2007 or before 2002. While one could say there shouldnt be any it always behooves one to cover thier butt.

Proc Format ; Value Year ; '01SEP01'D - '28AUG02'D = '2002' '01SEP02'D - '28AUG03'D = '2003' '01SEP03'D - '28AUG04'D = '2004' '01SEP04'D - '28AUG05'D = '2005' '01SEP05'D - '28AUG06'D = '2006' '01SEP06'D - '28AUG07'D = '2007' Other = 'XXXX' ; Run ;

Data Need ; Set Have ; FY = Put( CNDTLET , Year. ) ; Run ;

To me in some ways the format creates a more readable hunk of code. And readability is something I personally am always after.

Another solution would be to use the IntnX function to increment year to the bound you want by using the shift operators and the period operators. Then simply use the Year function.

Data _Null_ ; CnDtLet = '28Aug2002'd ; FY = Year( IntnX( 'Year.9' , CnDtLet , 1 , 'B' ) ) ; Put _All_ ; Run ;

On the other hand your post does bring up something that people using the select statement need to know before using it. Good post and keep up the good work Paul.

Toby Dunn

When everything is coming at you all at once, your in the wrong lane.

A truly happy person is someone who can smile and enjoy the scenery on a detour.

From: Paul St Louis <pstloui@DOT.STATE.TX.US> Reply-To: Paul St Louis <pstloui@DOT.STATE.TX.US> To: SAS-L@LISTSERV.UGA.EDU Subject: SELECT - Unsatisfied WHEN clause and no OTHERWISE clause Date: Tue, 5 Sep 2006 09:24:25 -0400

Learned about using the Select statement in the "SAS Programmiing by Example" by Ron Cody and Ray Pass... http://support.sas.com/publishing/bbu/companion_site/home.html#s

So I tried it: SELECT; WHEN ('01SEP01'D LE CNDTLET LE '28AUG02'D) FY='2002'; WHEN ('01SEP02'D LE CNDTLET LE '28AUG03'D) FY='2003'; WHEN ('01SEP03'D LE CNDTLET LE '28AUG04'D) FY='2004'; WHEN ('01SEP04'D LE CNDTLET LE '28AUG05'D) FY='2005'; WHEN ('01SEP05'D LE CNDTLET LE '28AUG06'D) FY='2006'; WHEN ('01SEP06'D LE CNDTLET LE '28AUG07'D) FY='2007'; END;

Error message in log: ERROR: Unsatisfied WHEN clause and no OTHERWISE clause.

This puzzled me. Unsatisfied When clause? Also, for this program, I saw no apparent need for an Otherwise clause and left it out. I then tried adding an otherwise clause, stuck in a proc sort, then run. Did not work.

It took a little digging but I found a good solution at: http://tinyurl.com/p5yxs

Turns out that Otherwise clause has to be included and needs to be followed by end. Thought I'd share this with others who are also in the begginning stages of their SAS learning.


Back to: Top of message | Previous page | Main SAS-L page