Date: Thu, 6 Oct 2011 11:23:52 -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: <201110061558.p96AmH0t000825@waikiki.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1
Varied as in it is varied from record to record?
That should be fine in the case of the _infile_ magic...
data have;
array s $ s1-s10;
do _x = 1 to 50000;
numcols = ceil(ranuni(7)*10);
do _t = 1 to numcols;
s[_t] = byte(floor(ranuni(7)*26)+65);
if ranuni(7) < 0.5 then s[_t]='|';
end;
str = compress(catx('*',of s1-s10),'|');
output;
call missing(of s:);
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 Thu, Oct 6, 2011 at 10:58 AM, Ben <benpub7@yahoo.com> wrote:
> Your methods are great, but what if the case is a little bit complcated
> like following:
>
> the demension of array is going to be varied from 2 to 50.
>
>
> ************************;
> data _null_;
> infile datalines ...;
>
>
> datalines;
> aa*bb**dd*ee****ii
> a*b
> ;;;;
>
> ***********************;
>
>
>
>
>
> On Wed, 5 Oct 2011 17:19:56 -0400, 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
>
|