home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / bit / listserv / sasl / 4100 < prev    next >
Encoding:
Text File  |  1992-09-08  |  4.7 KB  |  113 lines

  1. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  2. Path: sparky!uunet!paladin.american.edu!auvm!SUVM.BITNET!SASMAINT
  3. Message-ID: <SAS-L%92090903115059@AWIIMC12.IMC.UNIVIE.AC.AT>
  4. Newsgroups: bit.listserv.sas-l
  5. Date:         Tue, 8 Sep 1992 13:30:21 EDT
  6. Reply-To:     "Nelson R. Pardee" <SASMAINT@SUVM.BITNET>
  7. Sender:       "SAS(r) Discussion" <SAS-L@UGA.BITNET>
  8. From:         "Nelson R. Pardee" <SASMAINT@SUVM.BITNET>
  9. Subject:      Digits printed in PROC PRINT
  10. Lines: 101
  11.  
  12. About a month ago I wrote to SAS-L:
  13.  >Without a format, PROC PRINT prints vars using BEST12.- almost!
  14.  >  If it doesn't need 12 columns, it uses fewer.  It's nice
  15.  >  that if the values falling on a given page are small, it uses fewer
  16.  >  columns. I have a variable with a wide range of values- sometimes
  17.  >  more than 12 digits, so they are printed in exponential format, which
  18.  >  is unacceptable.  I don't want to use a format statement like
  19.  >  format var BEST15.;
  20.  >  since then the variable will be printed using 15 columns even if it
  21.  >  doesn't need that many.  Any suggestions on how I can get it to not
  22.  >  use exponential format for larger values, but still use the minimum
  23.  >  number of columns?
  24.  >
  25.  >I'm running on CMS, but that shouldn't matter.
  26. Several folks, including Phil Miller, Kernon Gives, Howard Schreier,
  27. and Bob Snyder made suggestions. Bob's suggestion seemed to provide
  28. the best solution using PROC FORMAT with DEFAULT=. It's right there
  29. in the manual (well, but without an example to suggest how to use).
  30.  
  31. One note on printing with *NO* format:
  32. you may in fact get more than 12 digits, depending on the values
  33. of the numbers printed. See below.
  34.  ---------------------------
  35. 1          options ls=79 nocenter;
  36. 2          *TRYING TO PRINT NUMBERS WITH MORE THAN 12 DIGITS AND RETAINING
  37. 3           THE CAPABILITY OF USING FEWER THAN 12 COLUMNS WHEN NOT NEEDED;
  38. 4
  39. 5          DATA X;              *CREATE SOME SAMPLE DATA;
  40. 6          INPUT X @@; N+1;
  41. 7           if _n_=1 then put _infile_;
  42. 8          CARDS;
  43.  
  44. 10  123456789012  1234567890123  12345678901.3  123456.7890123
  45. NOTE: SAS went to a new line when INPUT statement reached past the end of a
  46.       line.
  47. NOTE: The data set WORK.X has 5 observations and 2 variables.
  48.  ------------------------------------------------------------------
  49. 11         PROC PRINT;
  50. 12          title 'print with SASs default format (which is best12.)';
  51. 13          TITLE2 'Note: prints more than 12 digits but truncates
  52. 123456.7890123';
  53. NOTE:At least one W.D format was too small for the number to be printed.
  54.  The decimal may be shifted by the "BEST" format.
  55.  
  56. OBS                  X    N
  57.  1               10.00    1
  58.  2     123456789012.00    2
  59.  3     1234567890123.0    3
  60.  4      12345678901.30    4
  61.  5           123456.79    5
  62.  ------------------------------------------------------------------
  63. 15         PROC PRINT data=X(WHERE=(N^=5));
  64. 16 title'Same, except obs 123456.7890123 deleted.Only 12 digits printed';
  65. NOTE: At least one W.D format was too small for the number to be printed.
  66.       The decimal may be shifted by the "BEST" format.
  67.  
  68. OBS               X    N
  69.  1               10    1
  70.  2     123456789012    2
  71.  3     1.2345679E12    3
  72.  4      12345678901    4
  73.  ------------------------------------------------------------------
  74. 18        proc print data=x(where=(n=1));
  75. 19        title 'Print 2 digit number with no format';
  76. 20        title2 'Note X uses the minimum number of columns on the page';
  77.  
  78. OBS     X    N
  79.  1     10    1
  80.  ------------------------------------------------------------------
  81. 22         proc print data=x(where=(n=1));
  82. 23          format x best13.;
  83. 24 title 'Print 2 digit number with BEST13.';
  84. 25 title2'Note column for X occupies all 13 columns although not needed';
  85.  
  86. OBS                X    N
  87.  1                10    1
  88.  ------------------------------------------------------------------
  89. 31         proc format;               *Now- the solution;
  90. 32          value x (default=20) ;
  91.  ------------------------------------------------------------------
  92. 34         proc print data=x;
  93. 35          title 'Print numbers w/special format. All digits printed';
  94. 36          format x x.;
  95.  
  96. OBS          X           N
  97.  1                 10    1
  98.  2       123456789012    2
  99.  3      1234567890123    3
  100.  4      12345678901.3    4
  101.  5     123456.7890123    5
  102.  ------------------------------------------------------------------
  103. 39 proc print data=x(where=(n=1));
  104. 40 title 'Print 2 digit number w/special format. Uses minimum columns';
  105. 41          format x x.;
  106.  
  107. OBS    X     N
  108.  1     10    1
  109.  ------------------------------------------------------------------
  110.  --Nelson R. Pardee,  Computing Services, Syracuse University          --
  111.  --120 Hinds Hall, Syracuse, NY 13244-1190 USA   (315)443-1079         --
  112.  --Bitnet: SASMAINT@SUVM     Internet: SASMAINT@SUVM.ACS.SYR.EDU       --
  113.