Date: Tue, 29 Nov 2011 15:24:08 -0600
Reply-To: Joe Matise <snoopy369@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Joe Matise <snoopy369@GMAIL.COM>
Subject: Re: Merge/coding problem using index, find,
or some other SAS function (with have and need data)
In-Reply-To: <1322599936.72809.YahooMailClassic@web161605.mail.bf1.yahoo.com>
Content-Type: text/plain; charset=ISO-8859-1
data want;
set have;
_t=1;
do until missing(testvar);
testvar = put(scan(desc,_t),$DRUGS.); *assuming space delimited;
if testvar ne 'NOT FOUND' then do;
output; *presumably you want something more complex here;
call missing(testvar); *so you do not keep looking;
end;
_t+1;
end;
run;
You would also need to have a hlo='o' label='NOT FOUND' row in your
format. Not sure if the DO UNTIL loop is superior to testing to
determine how many words there are (counting ' ' characters).
-Joe
On Tue, Nov 29, 2011 at 2:52 PM, Paul Miller <pjmiller_57@yahoo.com> wrote:
> Hi Joe,
>
> Know I can create a format using code like that pasted below.
>
> What would the SCAN part look like?
>
> Thanks,
>
> Paul
>
>
> libname mylib oledb provider="microsoft.jet.oledb.4.0" preserve_tab_names=yes preserve_col_names=yes
> properties=('data source'="n:\drug formats.xls") provider_string="excel 8.0";
>
> data fmt;
> retain fmtname '$drugs';
> set mylib.'sheet1$'n end=last;
> run;
>
> libname mylib clear;
>
> proc format cntlin=fmt;
> select $drugs;
> run;
>
> proc delete data=fmt;
> run;
>
>
>
> --- On Tue, 11/29/11, Joe Matise <snoopy369@gmail.com> wrote:
>
>> From: Joe Matise <snoopy369@gmail.com>
>> Subject: Re: Merge/coding problem using index, find, or some other SAS function (with have and need data)
>> To: "Paul Miller" <pjmiller_57@yahoo.com>
>> Cc: SAS-L@listserv.uga.edu
>> Received: Tuesday, November 29, 2011, 2:26 PM
>> Hmmm. Are the individual pieces
>> always whole words? Like in your
>> example you had two words, one of which matched. If
>> that's the case,
>> then you could build a format list, and use SCAN to search
>> over the
>> word, checking each SCANned piece to see if it
>> mathces. Also, if you
>> do indeed have first part always being the match, you can
>> take
>> advantage of that, as pointed out earlier.
>>
>> -Joe
>>
>
>
|