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 2003, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 11 May 2003 09:58:57 -0400
Reply-To:     The Hendersons <z_munchkin@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         The Hendersons <z_munchkin@HOTMAIL.COM>
Subject:      Re: Formatting of value
Content-Type: text/plain; charset="iso-8859-1"

This might get you close. The macro builds a format that formats integers with no decimal places and all other values with one decimal.

I have not tested it with a large range of integer values to verify it, but depending on where your values came from (e.g., were they read in with no decimals or were they calculated and thus perhaps not quite exactly integers) you might need to tweak the values (e.g., round them first with some fuzz factor).

But the following should be a good start.

%macro buildformat(from=1,to=2); proc format; value decimal %do i = &from %to &to; &i = [8.] %end; other = [8.1]; ; run; %mend buildformat;

%buildformat(from=0,to=3);

data test; format formatted decimal.; do notformatted = 0 to 3.1 by .1; formatted = notformatted; output; end; run;

proc print; run;

HTH, -don h. ----- Original Message ----- From: "Roland" <roland@RASHLEIGH-BERRY.FSNET.CO.UK> Newsgroups: bit.listserv.sas-l To: <SAS-L@LISTSERV.UGA.EDU> Sent: Sunday, May 11, 2003 8:38 AM Subject: Re: Formatting of value

> Don't think you can. You will have to test the variable and do a conditional > put. > > data _null_; > x=5.0; > if mod(x,1)=0 then put x=6.; > else put x=8.1; > run; > > > "Magnusson Tomas" <tmagnusson@MEDISERVICE.CH> wrote in message > news:832CC537C7B2D311A8D40000F8771ADD93374A@MEDISERVICE_SRV... > > Dear all, > > I want to extend my knowledge about proc format and picture. > > How do I define a format that gives following output > > > > (only positive values possible) > > > > 120 (if no decimals ->no decimal output and no decimal > separator) > > 98.5 (rounded to 1 decimal if more than 1 decimal) > > 50.5 > > 50.3 > > 7 > > 0.5 > > 0.3 > > > > Best wishes > > Tom > > > > Tomas Magnusson > > Data Warehouse Manager > > MediService AG > > Ausserfeldweg 1 > > CH-4528 Zuchwil > > Switzerland > > tmagnusson@mediservice.ch >


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