LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (February 2002, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 12 Feb 2002 18:30:02 -0500
Reply-To:     "Dorfman, Paul" <Paul.Dorfman@BCBSFL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Dorfman, Paul" <Paul.Dorfman@BCBSFL.COM>
Subject:      Re: help for data  manipulation
Comments: To: sawir y <sawiry@UIDAHO.EDU>
Content-Type: text/plain; charset=iso-8859-1

Sawir,

In this particular case, one could code just

p = 'p' || put(_n_ , 1.) ;

But suppose you have 100 records, so that _n_ can range from 1 to 100. If you specify 3. to accommodate it, it may not be enough the next time when your code executes against 1000 records. Best. format tries to figure out how to print a SAS number in the most informational way. When you omit the width specification from Best., it defaults to 12, more than enough when dealing with practically any number of records on a file. However, because the format is thus wider than the number of digits it prints, the following occurs:

309 data _null_; 310 _n_ = 17 ; 311 p = 'p' || put(_n_ , best.) ; 312 put p=; 313 run;

p=p 17

The format right-justifies. The intervening blanks should be squeezed from between p and 17, hence the need for the LEFT function:

314 data _null_; 315 _n_ = 17 ; 316 p = 'p' || left (put(_n_ , best.)) ; 317 put p=; 318 run;

p=p17

Kind regards, ===================== Paul M. Dorfman Jacksonville, FL =====================

>>Paul, Thank you very much for your help. >>Could you tell me what does " best." do in your sas codes.

"Dorfman, Paul" <Paul.Dorfman@BCBSFL.COM> wrote in message news:10774B3B297237-01@mail.bcbsfl.com... > Sawir, > > Try this: > > data a ; > input y1 y2 ; > cards ; > 1 2 > 3 6 > 4 1 > 5 4 > 2 3 > ; > run ; > > data b (keep = p y); > set a ; > p = 'p' || left(put(_n_ , best.)) ; > do y = y1 , y2 ; > output ; > end ; > run ;

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.


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