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 (April 2010, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 13 Apr 2010 16:55:35 -0700
Reply-To:     William Krause <wkrause2003@YAHOO.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         William Krause <wkrause2003@YAHOO.COM>
Subject:      Re: Finding number in a string
Comments: To: Joe Matise <snoopy369@GMAIL.COM>
In-Reply-To:  <y2nb7a7fa631004131612q449ab9c4v293b877747b1e988@mail.gmail.com>
Content-Type: text/plain; charset=iso-8859-1

What I am trying to do is extract all the numbers from the string before the equal sign as well as the max numer from the string.  The numbers selected must come before the equal sign as  10=other  -- the number extracted would be 10.    The 4 lines listed below are actually one continuous string.   HTH   Bill K.  

--- On Tue, 4/13/10, Joe Matise <snoopy369@GMAIL.COM> wrote:

From: Joe Matise <snoopy369@GMAIL.COM> Subject: Re: Finding number in a string To: SAS-L@LISTSERV.UGA.EDU Date: Tuesday, April 13, 2010, 6:12 PM

Not sure I understand what you have and are looking for.  Is the set of strings a coding list?  What's the number variable - is it 1 to 10 equivalent of the string?

If I make a guess, I would say you should write those strings out to a format, and include an eleventh field which specifies that any other value is out of range.  Then use that format to determine where you should output the records.  Look up the documentation for PROC FORMAT for more details, but it's something like:

dataset: data cntlin_set; length label $50; fmtname = 'workf.'; *or $workf if your numeric variable is character; if _n_ = 1 then do;   hlo='o';   label='OUT OF RANGE';   output; end; hlo=' '; input start label $; output; datalines; <your 1 to 10 list with 1 going into start and the string into label> ;;;; run;

proc format lib=whatever cntlin=cntlin_set; quit;

-Joe

On Tue, Apr 13, 2010 at 5:56 PM, William Krause <wkrause2003@yahoo.com>wrote:

> I have a string as: >  1="A. Yard work" 2="B. Shopping work" 3="C. Car work" >  4="D. House work"  5="E. No work"  6="F. Business work" >  7="G. Comnputer work"  8="H. School Work  9="I. Home Work" > 10="X. Other " > > This is in a variable called work. > > I have response value 1 - 10 or some other values in a field call reply. > > How do I determine if the reply matches one of the numeric values in the > work variable.  Both reply and work variables are character varaiables. > > And if it is out of range as 0 or > 10, I would want to output into a > different dataset. > > Comments. > > Thanks for your  assistance. > > Bill K. >


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