home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / bit / listserv / sasl / 3403 < prev    next >
Encoding:
Text File  |  1992-07-23  |  4.8 KB  |  155 lines

  1. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  2. Path: sparky!uunet!paladin.american.edu!auvm!HILBERT.MATHS.UTAS.EDU.AU!MCPHERS
  3. X-Mailer: ELM [version 2.2 PL11]
  4. Message-ID: <9207231009.AA15227@hilbert.maths.utas.edu.au>
  5. Newsgroups: bit.listserv.sas-l
  6. Date:         Thu, 23 Jul 1992 20:09:45 EST
  7. Reply-To:     "D. Glen McPherson" <mcphers@HILBERT.MATHS.UTAS.EDU.AU>
  8. Sender:       "SAS(r) Discussion" <SAS-L@UGA.BITNET>
  9. From:         "D. Glen McPherson" <mcphers@HILBERT.MATHS.UTAS.EDU.AU>
  10. Subject:      permanent storage of formats.
  11. Lines: 142
  12.  
  13. The problem I posted earlier today about storage and usage of formats has
  14. been solved by Nathan and Anne. Thank you. I have included the program and
  15. pointed out the errors for others as ignorant as myself.
  16.  
  17. Glen McPherson
  18.  
  19.  
  20. ******************************************************************
  21. * PROGRAM
  22. *******************************************************************;
  23.  
  24. libname problem 'e:\sma352\sasdata';
  25.  
  26. data dset1;
  27.   infile 'e:\sma352\rawdata\a5x1.dat';
  28.   input freq @@;
  29.   label freq='Frequency';
  30.  
  31. data dset2;
  32.   do study = 1 to 8;
  33.      do cancer = 'no ', 'yes';
  34.         do smoker = 'no ', 'yes';
  35.            output;
  36.          end;
  37.       end;
  38.    end;
  39.   label cancer='Lung cancer?'
  40.         smoker = 'Smoker?';
  41.  
  42.  
  43. * The following library reference may be to any active library;
  44. * In my case I chose the library made active in this program;
  45.  
  46. proc format library=problem;
  47.   value $ fcancer 'no ' = 'Control'
  48.                 'yes' = 'Lung cancer';
  49.   value $ fsmoker 'no ' = 'Non-smoker'
  50.                 'yes' = 'Smoker';
  51.  
  52. run;
  53.  
  54.  
  55. data problem.a5x1;
  56.   merge dset2 dset1;
  57.  
  58. /*
  59. * THE FOLLOWING IS CRUCIAL: THE LIBRARY REFERENCE PRECEDING THE USE OF
  60. * OF THE PERMANENTLY STORED FORMAT MUST BE   library   AND MUST POINT TO
  61. * THE DIRECTORY IDENTIFIED BY THE LIBREF OPTION IN THE PROCEDURE FORMAT
  62. * WHICH CONSTRUCTED THE FORMATS  */
  63.  
  64. libname library 'e:\sma352\sasdata';
  65.  
  66. /*
  67. * In using the formats, I forgot to include the  $  sign to indicate they
  68. * are character formats */
  69.  
  70. proc print data=problem.a5x1;
  71.   id cancer smoker;
  72.   var freq;
  73.   format cancer $fcancer.;
  74.   format smoker $fsmoker.;
  75.   title 'Data for Assignment 5.1';
  76.  
  77. run;
  78.  
  79.  
  80.  
  81.   470    ******************************************************************
  82.   471    * LOG OUTPUT
  83.   472
  84. *******************************************************************;
  85.   473
  86.   474    libname problem 'e:\sma352\sasdata';
  87.   475
  88.   476    data dset1;
  89.   477      infile 'e:\sma352\rawdata\a5x1.dat';
  90.   478      input freq @@;
  91.   479      label freq='Frequency';
  92.   480
  93.   481    data dset2;
  94. NOTE: The infile 'e:\sma352\rawdata\a5x1.dat' is file
  95.       E:\SMA352\RAWDATA\A5X1.DAT.
  96. NOTE: 8 records were read from the infile E:\SMA352\RAWDATA\A5X1.DAT.
  97.       The minimum record length was 10.
  98.       The maximum record length was 14.
  99. NOTE: SAS went to a new line when INPUT statement reached past the end of a
  100.       line.
  101. NOTE: The data set WORK.DSET1 has 32 observations and 1 variables.
  102. NOTE: The DATA statement used 2.00 seconds.
  103.   482      do study = 1 to 8;
  104.   483         do cancer = 'no ', 'yes';
  105.   484            do smoker = 'no ', 'yes';
  106.   485               output;
  107.   486             end;
  108.   487          end;
  109.   488       end;
  110.   489      label cancer='Lung cancer?'
  111.   490            smoker = 'Smoker?';
  112.   491
  113.   492    libname library 'e:\sma352\sasdata';
  114.   493
  115.   494    proc format library=library;
  116. NOTE: The data set WORK.DSET2 has 32 observations and 3 variables.
  117. NOTE: The DATA statement used 2.00 seconds.
  118.   495      value $ fcancer 'no ' = 'Control'
  119.   496                    'yes' = 'Lung cancer';
  120. NOTE: Format $FCANCER has been output.
  121.   497      value $ fsmoker 'no ' = 'Non-smoker'
  122.   498                    'yes' = 'Smoker';
  123. NOTE: Format $FSMOKER has been output.
  124.   499
  125.   500    run;
  126. NOTE: The PROCEDURE FORMAT used 3.00 seconds.
  127.   501
  128.   502
  129.   503    data problem.a5x1;
  130.   504      merge dset2 dset1;
  131.   505
  132.   506
  133.   507    libname library 'e:\sma352\sasdata';
  134.   508
  135.   509    proc print data=problem.a5x1;
  136. NOTE: The data set PROBLEM.A5X1 has 32 observations and 4 variables.
  137. NOTE: The DATA statement used 2.00 seconds.
  138.   510      id cancer smoker;
  139.   511      var freq;
  140.   512      format cancer fcancer.;
  141. ERROR: Format FCANCER not found or couldn't be loaded.
  142.   513      format smoker fsmoker.;
  143.   514      title 'Data for Assignment 5.1';
  144.   515
  145.   516    run;
  146. NOTE: The SAS System stopped processing this step because of errors.
  147. NOTE: The PROCEDURE PRINT used 3.00 seconds.
  148. --
  149.  ---------------------------------------------------------------------------
  150. |  Glen McPherson            |                                   |  _--_|\  |
  151. |  Department of Mathematics |-----------------------------------| /      \ |
  152. |  University of Tasmania    |               E-Mail:             | \_.--._/ |
  153. |  Australia.                | mcphers@hilbert.maths.utas.edu.au |       *  |
  154.  ---------------------------------------------------------------------------
  155.