home *** CD-ROM | disk | FTP | other *** search
- Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
- Path: sparky!uunet!paladin.american.edu!auvm!HILBERT.MATHS.UTAS.EDU.AU!MCPHERS
- X-Mailer: ELM [version 2.2 PL11]
- Message-ID: <9207231009.AA15227@hilbert.maths.utas.edu.au>
- Newsgroups: bit.listserv.sas-l
- Date: Thu, 23 Jul 1992 20:09:45 EST
- Reply-To: "D. Glen McPherson" <mcphers@HILBERT.MATHS.UTAS.EDU.AU>
- Sender: "SAS(r) Discussion" <SAS-L@UGA.BITNET>
- From: "D. Glen McPherson" <mcphers@HILBERT.MATHS.UTAS.EDU.AU>
- Subject: permanent storage of formats.
- Lines: 142
-
- The problem I posted earlier today about storage and usage of formats has
- been solved by Nathan and Anne. Thank you. I have included the program and
- pointed out the errors for others as ignorant as myself.
-
- Glen McPherson
-
-
- ******************************************************************
- * PROGRAM
- *******************************************************************;
-
- libname problem 'e:\sma352\sasdata';
-
- data dset1;
- infile 'e:\sma352\rawdata\a5x1.dat';
- input freq @@;
- label freq='Frequency';
-
- data dset2;
- do study = 1 to 8;
- do cancer = 'no ', 'yes';
- do smoker = 'no ', 'yes';
- output;
- end;
- end;
- end;
- label cancer='Lung cancer?'
- smoker = 'Smoker?';
-
-
- * The following library reference may be to any active library;
- * In my case I chose the library made active in this program;
-
- proc format library=problem;
- value $ fcancer 'no ' = 'Control'
- 'yes' = 'Lung cancer';
- value $ fsmoker 'no ' = 'Non-smoker'
- 'yes' = 'Smoker';
-
- run;
-
-
- data problem.a5x1;
- merge dset2 dset1;
-
- /*
- * THE FOLLOWING IS CRUCIAL: THE LIBRARY REFERENCE PRECEDING THE USE OF
- * OF THE PERMANENTLY STORED FORMAT MUST BE library AND MUST POINT TO
- * THE DIRECTORY IDENTIFIED BY THE LIBREF OPTION IN THE PROCEDURE FORMAT
- * WHICH CONSTRUCTED THE FORMATS */
-
- libname library 'e:\sma352\sasdata';
-
- /*
- * In using the formats, I forgot to include the $ sign to indicate they
- * are character formats */
-
- proc print data=problem.a5x1;
- id cancer smoker;
- var freq;
- format cancer $fcancer.;
- format smoker $fsmoker.;
- title 'Data for Assignment 5.1';
-
- run;
-
-
-
- 470 ******************************************************************
- 471 * LOG OUTPUT
- 472
- *******************************************************************;
- 473
- 474 libname problem 'e:\sma352\sasdata';
- 475
- 476 data dset1;
- 477 infile 'e:\sma352\rawdata\a5x1.dat';
- 478 input freq @@;
- 479 label freq='Frequency';
- 480
- 481 data dset2;
- NOTE: The infile 'e:\sma352\rawdata\a5x1.dat' is file
- E:\SMA352\RAWDATA\A5X1.DAT.
- NOTE: 8 records were read from the infile E:\SMA352\RAWDATA\A5X1.DAT.
- The minimum record length was 10.
- The maximum record length was 14.
- NOTE: SAS went to a new line when INPUT statement reached past the end of a
- line.
- NOTE: The data set WORK.DSET1 has 32 observations and 1 variables.
- NOTE: The DATA statement used 2.00 seconds.
- 482 do study = 1 to 8;
- 483 do cancer = 'no ', 'yes';
- 484 do smoker = 'no ', 'yes';
- 485 output;
- 486 end;
- 487 end;
- 488 end;
- 489 label cancer='Lung cancer?'
- 490 smoker = 'Smoker?';
- 491
- 492 libname library 'e:\sma352\sasdata';
- 493
- 494 proc format library=library;
- NOTE: The data set WORK.DSET2 has 32 observations and 3 variables.
- NOTE: The DATA statement used 2.00 seconds.
- 495 value $ fcancer 'no ' = 'Control'
- 496 'yes' = 'Lung cancer';
- NOTE: Format $FCANCER has been output.
- 497 value $ fsmoker 'no ' = 'Non-smoker'
- 498 'yes' = 'Smoker';
- NOTE: Format $FSMOKER has been output.
- 499
- 500 run;
- NOTE: The PROCEDURE FORMAT used 3.00 seconds.
- 501
- 502
- 503 data problem.a5x1;
- 504 merge dset2 dset1;
- 505
- 506
- 507 libname library 'e:\sma352\sasdata';
- 508
- 509 proc print data=problem.a5x1;
- NOTE: The data set PROBLEM.A5X1 has 32 observations and 4 variables.
- NOTE: The DATA statement used 2.00 seconds.
- 510 id cancer smoker;
- 511 var freq;
- 512 format cancer fcancer.;
- ERROR: Format FCANCER not found or couldn't be loaded.
- 513 format smoker fsmoker.;
- 514 title 'Data for Assignment 5.1';
- 515
- 516 run;
- NOTE: The SAS System stopped processing this step because of errors.
- NOTE: The PROCEDURE PRINT used 3.00 seconds.
- --
- ---------------------------------------------------------------------------
- | Glen McPherson | | _--_|\ |
- | Department of Mathematics |-----------------------------------| / \ |
- | University of Tasmania | E-Mail: | \_.--._/ |
- | Australia. | mcphers@hilbert.maths.utas.edu.au | * |
- ---------------------------------------------------------------------------
-