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 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 17 Apr 2002 10:09:49 +0200
Reply-To:   Jim Groeneveld <J.Groeneveld@ITGROUPS.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Jim Groeneveld <J.Groeneveld@ITGROUPS.COM>
Subject:   Re: concatenate character variable
Comments:   To: Leslie King <doqkxl@HOTMAIL.COM>
Content-Type:   text/plain

Hi Leslie,

I shortened your variable names for use in SAS 6.12:

OPTIONS PS=63 LS=80;

data x; attrib servsect length=$8.; input memrefid servsect $ seq; cards; 2309202 1111 1 2309202 0 2 2309202 0.1 3 2309202 2.0 4 2309202 1111 5 2309202 0 6 2309202 0.1 7 2309202 2.0 8 2309202 2.2 9 2309202 2.2 10 2309202 2.2R 11 2309202 2.2S 12 2309202 4.50 13 2309202 4.52 14 2309202 4.11 15 2309202 1111 16 1120922 9.011 1 1120922 9.014 2 1120922 0.1 3 1120922 1.400 4 1120922 2.3 5 1120922 2.3 6 ; run;

PROC SORT DATA=x OUT=y (DROP=Seq); BY MemRefId Seq; RUN;

DATA z (DROP=ServSect); LENGTH Concat $200; RETAIN Concat ''; SET y; BY MemRefId; IF (FIRST.MemRefId) THEN Concat = ServSect; ELSE Concat = TRIM(Concat) || '-' || ServSect; IF (LAST.MemRefId) THEN OUTPUT; RUN;

PROC PRINT DATA=z; RUN;

Regards - Jim. -- Y. (Jim) Groeneveld, MSc IMRO TRAMARKO tel. +31 412 407 070 senior statist./data man. P.O. Box 1 fax. +31 412 407 080 J.Groeneveld@ITGroups.com 5350 AA BERGHEM, NL www.imrotramarko.com

My computer sometimes doesn't understand me; so do I, myself that is.

Notice of confidentiality: this e-mail may contain confidential information intended for the addressed recipient only. If you have received this e-mail in error please delete this e-mail and please notify the sender so that proper delivery can be arranged.

> -----Original Message----- > From: Leslie King [SMTP:doqkxl@HOTMAIL.COM] > Sent: Wednesday, April 17, 2002 6:24 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: concatenate character variable > > Can someone out there give me a hand? I just don't know how to use a > do loop to concatenate a character variable into a "stream". Or maybe > some other smart way like first.obs? The number of records for each > member varies. > > I've included a sample dataset and the output file. > > Thanks for reply. doqkxl@hotmail.com > > I'd like to have a dataset that has: > mem_ref_id svc_stream > 2309202 1111-0-0.1-1111-0-0.1-2.0-2.2-2.2-2.2R-2.2S-4.50-4.52-4.11 > 1120922 9.011-9.014-0.1-1.400-2.3-2.3 > > > data x; > attrib service_section length=$8.; > input mem_ref_id service_section $ seq; > cards; > 2309202 1111 1 > 2309202 0 2 > 2309202 0.1 3 > 2309202 2.0 4 > 2309202 1111 5 > 2309202 0 6 > 2309202 0.1 7 > 2309202 2.0 8 > 2309202 2.2 9 > 2309202 2.2 10 > 2309202 2.2R 11 > 2309202 2.2S 12 > 2309202 4.50 13 > 2309202 4.52 14 > 2309202 4.11 15 > 2309202 1111 16 > 1120922 9.011 1 > 1120922 9.014 2 > 1120922 0.1 3 > 1120922 1.400 4 > 1120922 2.3 5 > 1120922 2.3 6 > ; > run;


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