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 (April 2005, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 27 Apr 2005 11:42:13 -0700
Reply-To:     Jack Hamilton <jfh@STANFORDALUMNI.ORG>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jack Hamilton <jfh@STANFORDALUMNI.ORG>
Subject:      Re: display numeric vars with decimals
Comments: To: lchen@rhoworld.com
In-Reply-To:  <200504271106450890.004D4EB5@mailserver.algx.net>
Content-Type: text/plain; charset="us-ascii"

Ling Yun Chen wrote:

> Hi Jim, you are right, however, my criterion is more > complicated than that. > I have a third variable C that determines whether the values > of A should > be displayed as 2 decimals, 1 decimal, or as integers.

It would have been helpful if you had mentioned this key piece of information in your first message.

> So I > cannot break > up the values of A like you suggested in your proc format > statement. For > example, if C=1, then whatever value A has, it needs to be > displayed as 1 > decimal, if C=2, then the values of A should be displayed as > 2 decimals. > Any ideas? Thanks!

===== data test (keep=decimals value displayed); do i = 1 to 5; do decimals = 0 to 3; value = ranuni(95605) * 10; displayed = value; output; end; end; stop; run;

proc report data=test nowindows missing nocenter; columns value decimals displayed; define _all_ / display; compute displayed; call define(_col_, 'format', '10.' || put(decimals, z1.0)); endcomp; run; =====

prints:

===== The SAS System 11:23 Wednesday, April 27, 2005 5

value decimals displayed 3.4648784 0 3 3.3165982 1 3.3 2.0278367 2 2.03 8.0749122 3 8.075 8.1445687 0 8 7.6102304 1 7.6 5.2384895 2 5.24 3.8716015 3 3.872 5.5787562 0 6 0.951658 1 1.0 9.5194012 2 9.52 6.4120504 3 6.412 7.6308912 0 8 1.8146458 1 1.8 2.6590652 2 2.66 2.289426 3 2.289 0.5009372 0 1 7.2236493 1 7.2 6.0467117 2 6.05 2.5131059 3 2.513 =====

Where "displayed" is "value" printed with "decimals" decimal points.


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