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 (May 2001, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 30 May 2001 14:21:37 +0100
Reply-To:     Peter Crawford <peter.crawford@DB.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Peter Crawford <peter.crawford@DB.COM>
Subject:      Re: Data _Null_ Help please
Comments: To: CEdel@de.imshealth.com, lastgear1@MINDSPRING.COM
Content-type: text/plain; charset=iso-8859-1

Hi Christoph well done raising funds for a worthy cause at that Frankfurt Fun run. You have pointed out the error in my reading - very generously Erica wants to write not read !! mea culpa !

Hi Christoph / Erica Typically of sas the opposite direction is achieved with as much (and perhaps more) simplicity than my earlier suggestion input @'string'

When sas uses implied (=defined before the put statement) formats on writing, the variable is left aligned in the output buffer, after the format is used to present the value.

So Christoph's code below can deliver what was sought even simpler

235 data _null_; 236 set work.test; 237 format x comma32. ; 238 put @10 "There were " x 239 "guaranties for your district"; 240 run;

There were 12,726 guaranties for your district There were 1,122,726 guaranties for your district NOTE: The DATA statement used 0.06 seconds.

If you want two blanks after the value, either start the string on logline 239 with a blank or use the +1 pointer controls to move the output buffer position along another character like put @10 "There were " x +1 "guaranties for your district";

There are many (and more complicated) resources available to discover and control the "current position" in the output buffer

...enjoy

Datum: 30/05/2001 10:57 An: SAS-L@listserv.uga.edu

Antwort an: CEdel@de.imshealth.com

Betreff: Re: Data _Null_ Help please Nachrichtentext:

Erica (from Bill Eshelman's account),

perhaps I have had a short night's sleep only after the JP Morgan Chase Corporate Challenge fun run plus party here in Frankfurt, but I get the impression that Peter Crawford assists in READing your desired report format properly, and Paul Dorfman's very appropriate strategy outline to a solution may require more experience than you have if you are fairly new to SAS (so pointer control is your favorite topic these days?). I think you just want to WRITE it without the leading and trailing blanks around your formatted value.

If that is the case, here goes (tested code): (This assumes you know already that 32 minus commas will suffice to represent your data)

data work.test;

x = 12726 ; output; x = 1122726; output; run;

data _null_; set work.test;

attrib char length = $32; char = trim( left( put( x, comma32. ) ) );

put @10 "There were " char "guaranties for your district"; run;

which yields

47 data _null_; 48 set work.test; 49 50 attrib char length = $32; 51 char = trim( left( put( x, comma32. ) ) ); 52 53 put @10 "There were " char 54 "guaranties for your district"; 55 run;

There were 12,726 guaranties for your district There were 1,122,726 guaranties for your district NOTE: There were 2 observations read from the data set WORK.TEST. NOTE: DATA statement used: real time 0.02 seconds cpu time 0.02 seconds

BTW if you are new to SAS-L: remember those two names Peter and Paul. There is always something to learn from their postings - I was completely unaware of the input @ "string" technique, but then, I never had to...

Good night,

Christoph Edel

Christoph Edel Produktionssupport IMS Health Frankfurt (Germany) Phone: +49-69-6604-789 Hahnstraße 30-32 Fax: +49-69-6604-600 60528 Frankfurt am Main e-mail: cedel@de.imshealth.com

Euler to Diderot: "Sir, (a+b**n)/n = x, hence God exists; reply!"

> -----Original Message----- > From: Bill Eshelman [SMTP:lastgear1@MINDSPRING.COM] > Sent: Wednesday, May 30, 2001 2:34 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Data _Null_ Help please > > Hi. I am fairly new to SAS and I am working on a report using Data > _Null_, > I have several sentences with some dollar amounts. On one person's report > the dollar amount may be only 6 figures, but on another it may be 10 > figures. How do I write it so it will have the correct spacing for each > report regardless of the number of digits. > i.e instead of looking like this on one report > there were 12,726 guaranties for your district > and looking like this on another report > there were 1,122,726 guaranties for your district > > I want it to look like this for each report > there were 12,726 guaranties for your district > and looking like this on another report > there were 1,122,726 guaranties for your district. > > Thanks in advance for any help. - Erica

--

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.


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