| Date: | Wed, 5 Oct 2011 19:56:20 -0500 |
| Reply-To: | Joe Matise <snoopy369@GMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Joe Matise <snoopy369@GMAIL.COM> |
| Subject: | Re: Scanning the string |
|
| In-Reply-To: | <201110060020.p95JmOM5026217@waikiki.cc.uga.edu> |
| Content-Type: | text/plain; charset=ISO-8859-1 |
What does that have to do with anything? _infile_ magic works on any
number of records. You're not inputting from the datalines, you're
just cheating and pretending you have datalines.
Example:
data have;
array s $ s1-s10;
do _x = 1 to 50000;
do _t = 1 to dim(s);
s[_t] = byte(floor(ranuni(7)*26)+65);
if ranuni(7) < 0.5 then s[_t]='|';
end;
str = compress(catx('*',of s1-s10),'|');
output;
end;
keep str;
run;
data want;
set have;
infile cards dlm='*' truncover dsd;
input @;
_infile_ = str;
input @1 (s1-s10) (:$8.) @@;
cards;
;;;;
run;
-Joe
On Wed, Oct 5, 2011 at 7:20 PM, Ben <benpub7@yahoo.com> wrote:
> Thanks, but it seems not practical. there are thousands of records. the STR
> can be totally different. At another position, it can be STR="aa**cc***" etc.
>
> Thanks for your quick response.
>
> Ben
>
>
> On Wed, 5 Oct 2011 18:31:34 -0500, Data _null_; <iebupdte@GMAIL.COM> wrote:
>
>>Infile Magic?
>>
>>166 data _null_;
>>167 STR="aa*bb**dd*ee****ii";
>>168 infile cards dsd dlm='*' missover;
>>169 input @;
>>170 _infile_ = str;
>>171 input @1 (s1-s10)(:$8.);
>>172 put (S:)(=);
>>173 cards;
>>
>>STR=aa*bb**dd*ee****ii s1=aa s2=bb s3= s4=dd s5=ee s6= s7= s8= s9=ii s10=
>>
>>
>>On Wed, Oct 5, 2011 at 6:21 PM, Ben <benpub7@yahoo.com> wrote:
>>> forgot to tell you, I am still using SAS9.1.3. Thank you for your kindly
>>> response.
>>>
>>> ben
>>>
>>> On Wed, 5 Oct 2011 16:27:49 -0500, Data _null_; <iebupdte@GMAIL.COM> wrote:
>>>
>>>>SCAN with M modifier,
>>>>
>>>>Click that little icon that looks like a book with a ? on it. :-)
>>>>
>>>>On Wed, Oct 5, 2011 at 4:19 PM, Ben <benpub7@yahoo.com> wrote:
>>>>> data _null_;
>>>>> STR='aa*bb**dd*ee****ii";
>>>>>
>>>>> put s1= s2= s3= s4= s5= s6= s7= s8= s9= s10=;
>>>>> run;
>>>>>
>>>>> *the desired results;
>>>>>
>>>>> s1='aa' s2='bb' s3='' s4='dd' s5='ee' s6='' s7='' s8='' s9='' s10='ii'
>>>>>
>>>>> **instead of;
>>>>> s1='aa' s2='bb' s3='dd' s4='ee' s5='ii'
>>>>>
>>>>> Thanks
>>>>>
>>>>> ben
>>>>>
>>>
>
|