|
Jay,
There is no need to go character by character. SAS be praised, there is a
function for it. Behold:
21 data a ;
22 array let(5) $1. ;
23 input let(*) ;
24 list ;
25 cards ;
RULE: ----+----1
26 a b c d e
27 1 2 3 4 5
28 * + - = <
NOTE: The data set WORK.A has 3 observations and 5 variables.
29 ;
30 run ;
31 data _null_ ;
32 set a ;
33 array let(*) let: ;
34 length str_5 $5. ;
35 str_5 = peekc ( addr(let(1)) , dim(let) ) ;
36 put let(*) str_5= ;
37 run ;
a b c d e str_5=abcde
1 2 3 4 5 str_5=12345
* + - = < str_5=*+-=<
Kind regards,
==================
Paul M. Dorfman
Jacksonville, FL
==================
> -----Original Message-----
> From: Jay Weedon [mailto:jweedon@EARTHLINK.NET]
>
> On Wed, 17 Jul 2002 11:57:41 +0000 (UTC), Arthur Ellen
> <arte@panix.com> wrote:
>
> >I'm trying to build a string from
> >an array of characters; I'v tried
> >using the concatenation operator alone
> >and then the SUBSTR function with
> >some odd results.
> >
> >My goal is ABCDE
> >
> >
> >DATA READIT;
> > ARRAY LET(5) $ 1.;
> > INPUT (LET1-LET5) ($CHAR1.);
> > PUT LET1-LET5;
> > *PUT (LET1-LET5)($CHAR1.);
> > CARDS;
> >ABCDE
> >;
> >RUN;
> >
> >
> >DATA MAKESTR;
> > SET READIT;
> > ARRAY LET LET1-LET5;
> > LENGTH STR_5 $ 5.;
> > DO J=1 TO 5;
> > STR_5=SUBSTR(STR_5,J) || LET(J);
> > PUT J Z3.0 @10 STR_5 @20 LET(J);
> > END;
> >RUN;
>
> How about
>
> data makestr;
> length str $5;
> set readit;
> aray let let1-let5;
> str=' ';
> do over let;
> str=compress(str||let);
> end;
> put str;
> run;
>
> JW
>
Blue Cross Blue Shield of Florida, Inc., and its subsidiary and
affiliate companies are not responsible for errors or omissions in this e-mail message. Any personal comments made in this e-mail do not reflect the views of Blue Cross Blue Shield of Florida, Inc.
|