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 (July 2001, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 16 Jul 2001 11:53:33 -0600
Reply-To:     Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
Subject:      Re: how would you write..?
Comments: To: yeon_rhee@HOTMAIL.COM
Content-Type: text/plain; charset=us-ascii

You could use

if z in ('A', 'B', 'C', 'D', 'E') then count + 1;

or

if 'A' <= z <= 'E'

This last solution works only if the actual values you want to check for are in a sequence. If you're on an EBCDIC system, only some sequences work as expected. For example, on an IBM machine,

if z in ('G', 'H', 'I', 'J', 'K', 'L');

is not the same as

if 'G' <= z <= 'L';

-- JackHamilton@FirstHealth.com Development Manager, Technical Group METRICS Department, First Health West Sacramento, California USA

>>> ywr1 <yeon_rhee@HOTMAIL.COM> 07/16/2001 7:16 AM >>> in proc iml,

i would like to write program that counts how many elements in z equat to either 'A','B','C' 'D' or 'E'

so i wrote,

z={'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H'}; nc=ncol(z); count=0; do i=1 to nc; if z='A' | z='B' |z='C' | z='D' | z='E' then count=count+1; end;

#from above statements, how can i avoid writing 'z=' 5 times?


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