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 (August 2007, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 30 Aug 2007 14:21:34 -0400
Reply-To:     Nathaniel.Wooding@DOM.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Nat Wooding <Nathaniel.Wooding@DOM.COM>
Subject:      Re: How to cut a text string ??
Comments: To: "Sridhar, Nagakumar" <nagakumar.sridhar@spcorp.com>
In-Reply-To:  <809BA36B4233FB4190D6D5A4C8BFA66101F7FDBA@KENMSG26.us.schp.com>
Content-type: text/plain; charset=US-ASCII

Kumar

You are quite right. It needs a Compbl in place of the Cat and the contents of the parentheses need editing. I don't have V8 here but I don't see any other V9 functions.

Data test; infile cards missover; Input var1 $50. ; cards; THE MAN IS ON THE HILL HAS TO CLIMB DOWN SLOWLY ; Run ;

data need (keep=var2); length var2 $ 50 ; set test; words = length(var1) - length(compress(var1)) +1; do i = 1 to ceil(words/3); var2 = compbl( scan(var1,1) || ' ' || scan(var1,2) || ' ' || scan(var1, 3));

output; var1 = left(substr(var1,1+length(var2))); end; run;

proc print data = need; run;

Nat Wooding Environmental Specialist III Dominion, Environmental Biology 4111 Castlewood Rd Richmond, VA 23234 Phone:804-271-5313, Fax: 804-271-2977

"Sridhar, Nagakumar" <nagakumar.sridha To r@spcorp.com> <Nathaniel.Wooding@DOM.COM> cc 08/30/2007 02:15 PM Subject RE: Re: How to cut a text string ??

This looks like it is still V9. It generates an error:

NOTE: SCL source line. 37 var2 = cat(scan(var1,1),' ',scan(var1,2),' ',scan(var1,3)); --- 68 ERROR 68-185: The function CAT is unknown, or cannot be accessed.

Kumar

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Nat Wooding Sent: Thursday, August 30, 2007 2:11 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: How to cut a text string ??

In that case, try

Data test; infile cards missover; Input var1 $50. ; cards; THE MAN IS ON THE HILL HAS TO CLIMB DOWN SLOWLY ; Run ;

data need (keep=var2); length var2 $ 50 ; set test; words = length(var1) - length(compress(var1)) +1; do i = 1 to ceil(words/3); var2 = cat(scan(var1,1),' ',scan(var1,2),' ',scan(var1,3)); output; var1 = left(substr(var1,1+length(var2))); end; run;

proc print data = need; run;

Nat Wooding Environmental Specialist III Dominion, Environmental Biology 4111 Castlewood Rd Richmond, VA 23234 Phone:804-271-5313, Fax: 804-271-2977

SAS_learner <proccontents@GMA IL.COM> To Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU Discussion" cc <SAS-L@LISTSERV.U GA.EDU> Subject Re: How to cut a text string ??

08/30/2007 01:55 PM

Please respond to SAS_learner <proccontents@GMA IL.COM>

My bad I forgot to tell you I am still using sas v8

thanks

On 8/30/07, Jack Clark <JClark@chpdm.umbc.edu> wrote: > > Will this work? > > Data test; > infile cards missover; > Input var1 $50. ; > cards; > THE MAN IS ON THE HILL HAS TO CLIMB DOWN SLOWLY > ; > Run ; > > > data need (keep=var2); > length var2 $ 50 ; > set test; > do i = 1 to ceil(countw(var1)/3); > var2 = cat(scan(var1,1),' ',scan(var1,2),' ',scan(var1,3)); > output; > var1 = left(substr(var1,1+length(var2))); > end; > run; > > proc print data = need; > run; > > > Jack Clark > Research Analyst > Center for Health Program Development and Management University of > Maryland, Baltimore County > > > -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of > SAS_learner > Sent: Thursday, August 30, 2007 12:54 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: How to cut a text string ?? > > Hello guys, > > I know something like has been asked before or done before but I could

> not find it in earlier Postings, what I need to do is count number of

> words in > a line and after 3rd word ( This is for now may change later ) I need to > break the line and make it as new Record . For example > I have a variable called Comment > > Data test ; > Input Comment $100. > Datalines; > THE MAN IS ON THE HILL HAS TO CLIMB DOWN SLOWLY > ; > Run ; > You see that Comment is one big line but I need to put in data set in > a such a way > Data test ; > Input Comment $100. > Datalines; > THE MAN IS > ON THE HILL > HAS TO CLIMB > DOWN SLOWLY > ; > Run ; > > I am doing this Just for a Listing sake and there there of lot other > variables along with it , If anybody earlier did some thing similar > can you share that macro with me > > thanks >

----------------------------------------- CONFIDENTIALITY NOTICE: This electronic message contains information which may be legally confidential and/or privileged and does not in any case represent a firm ENERGY COMMODITY bid or offer relating thereto which binds the sender without an additional express written confirmation to that effect. The information is intended solely for the individual or entity named above and access by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution, or use of the contents of this information is prohibited and may be unlawful. If you have received this electronic transmission in error, please reply immediately to the sender that you have received the message in error, and delete it. Thank you. ********************************************************************* This message and any attachments are solely for the intended recipient. If you are not the intended recipient, disclosure, copying, use or distribution of the information included in this message is prohibited -- Please immediately and permanently delete.


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