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 (November 2002, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 22 Nov 2002 18:10:51 -0500
Reply-To:     Larry Bertolini <bertolini.1@OSU.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Larry Bertolini <bertolini.1@OSU.EDU>
Organization: Ohio State University
Subject:      Re: Parsing a comma delimited column
Content-Type: text/plain; charset=us-ascii

Paul Dorfman wrote:

> ----Original Message Follows---- > From: Larry Bertolini <bertolini.1@OSU.EDU> > But looking at these two expressions (and assuming that we have > already specified "length foo $6;"): > foo = substr('1234567890123456', 1) ; > foo = put ('1234567890123456', $6.) ; > It seems that, in both cases, we only want the first 6 characters; > in which case, why not just: > foo = '1234567890123456'; > which, on my system, takes only 40% of the CPU as > the "put" function. > > Larry, > > Absolutely true, but of course in general we would have a string variable as > the first argument to SUBSTR() rather than a character literal. It would > rarely make any sense to use any function to manipulate a literal string > value, except for the REPEAT(). > >

Agreed; and using a string variable:

data; charvar = '0123456789012345'; length foo $6; do i=1 to 1e7; <assignment> end; displen = length(foo); storlen = length(foo); put foo= displen= storlen=; run;

CPU seconds used for various <assignment> on my PC:

foo = substr(charvar,1,6); 9.73 seconds foo = substr(charvar,1); 5.65 seconds foo = put(charvar,$6.); 1.53 seconds foo = charvar; 0.39 seconds

I guess I'm missing your point; how do the first three types of assignment differ from from the fourth? Don't all four of them assign the first 6 bytes of charvar to foo?

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