Home
Contents
GENERAL GUIDELINES:
Windows in SAS
File management
The SAS Program
Program syntax
Debugging tips
USING SAS PROGRAMMING TO:
1. Prepare the data set
Types of data
Example programs
2. View the data
SAS Procedures
3. Explore the data
Numeric statistics
Frequency tables
4. Manipulate the data
Basic techniques
New variables
5. Adding Variables and
Observations to Data Sets
The SET Statement
The MERGE Statement
6. Data Processing
ARRAY Statement
Do Loops
By-Group Processing
RETAIN Statement
NON-PROGRAMMING
Alternatives
SAMPLE DATA SETS:
Height/weight
Height/weight/region
Simulated clinical data
Simulated Manitoba Health
|
Sample Data Sets: Manitoba Health - Log 2
573 options linesize=min;
574
575 **==================================**
576 ** f=readmb2.sas **
577 ** **
578 ** This program creates a temporary **
579 ** SAS data set from the simulated **
580 ** Manitoba Health data **
581 ** and adds formats and labels. **
582 **==================================**;
583
584 /* Assign a name ("rawdata") to the path and file */
585
586 filename rawdata
587 'c:\My Documents\My SAS Files\sasmanual\data\fivet93m.raw';
588
589
590 /* Create formats that can be used to label values */
591 %include
592 'c:\My Documents\My SAS Files\sasmanual\formats\fmts95.sas';
NOTE: Format $ABSTYPL is already on the library.
NOTE: Format $ABSTYPL has been output.
NOTE: Format $CHARL is already on the library.
NOTE: Format $CHARL has been output.
NOTE: Format $DISCREL is already on the library.
NOTE: Format $DISCREL has been output.
NOTE: Format $GENDERL is already on the library.
NOTE: Format $GENDERL has been output.
NOTE: Format $ICD17L is already on the library.
NOTE: Format $ICD17L has been output.
NOTE: Format $INCDRL is already on the library.
NOTE: Format $INCDRL has been output.
NOTE: Format $REGIONL is already on the library.
NOTE: Format $REGIONL has been output.
NOTE: Format $RISKL is already on the library.
NOTE: Format $RISKL has been output.
NOTE: Format $SCHEDL is already on the library.
NOTE: Format $SCHEDL has been output.
NOTE: Format $SEVRL is already on the library.
NOTE: Format $SEVRL has been output.
NOTE: Format $TREATYL is already on the library.
NOTE: Format $TREATYL has been output.
NOTE: Format $TRNADML is already on the library.
NOTE: Format $TRNADML has been output.
NOTE: Format $TRNDISL is already on the library.
NOTE: Format $TRNDISL has been output.
NOTE: Format $TYPEHL is already on the library.
NOTE: Format $TYPEHL has been output.
NOTE: Format $WBURGL is already on the library.
NOTE: Format $WBURGL has been output.
NOTE: PROCEDURE FORMAT used:
real time 0.16 seconds
cpu time 0.16 seconds
685
686 /* Begin the DATA step */
687
688 DATA TEST; /* Create "test" data set */
689 INFILE RAWDATA; /* Read the external data */
690
691 /* Assign variable names, types & locations */
692 INPUT
693 NCASE $ 1-5
694 GENDER $ 6
695 AGE 7-9
696 LOS 10-13
697 NDAYICU 14-17
698 TRANADM $ 18
699 TRANDIS $ 19
700 OP01 $ 20-23 /* This is numeric 0 */
701 DIAG01 $ 24-28 /* This is numeric 0 */
702 DIAG02 $ 29-33 /* This is numeric 0 */
703 TOTCHAR 34-35
704 CHARYES $ 37
705 SCHEDULE $ 38
706 RISKDRG $ 39
707 @40 DRGWT 6.4 /* 6 columns, incl. 4 decimal*/
708 DRG $ 46-48
709 WBURG $ 49
710 DISCRE $ 50
711 REGIONRE $ 51
712 REGIONH $ 52
713 INCDR $ 53
714 TYPEHSP $ 54
715 DEATHSEP 55-58
716 DRGRGN $ 59-63
717 SEVERDRG $ 64
718 @65 RDRGWT 6.4
719 CMG $ 71-73
720 @74 RIW 7.4
721 TREATY $ 81
722 ABSTYPE $ 82
723 DAYSFRPR 83-85
724 DAYSTOR 86-88
725 @89 ICD17BRK $char2. /* Keep leading spaces */
726 ; /* End of INPUT statement*/
727
728 /*Apply the formats to label the values */
729 /*Also use LABEL statement to label the variables */
730 %include
731 'c:\My Documents\My SAS Files\sasmanual\formats\lbls93.sas';
781
782
783 run;
NOTE: The infile RAWDATA is:
File Name=c:\My Documents\My SAS
Files\sasmanual\data\fivet93m.raw,
RECFM=V,LRECL=256
NOTE: 5000 records were read from the infile RAWDATA.
The minimum record length was 90.
The maximum record length was 90.
NOTE: The data set WORK.TEST has 5000 observations and 33
variables.
NOTE: DATA statement used:
real time 1.08 seconds
cpu time 0.99 seconds
783! /* End of DATA step */
784
785 /* Obtain general information about the data set */
786 proc contents data=test; /* Begin PROC step */
787 run;
NOTE: PROCEDURE CONTENTS used:
real time 0.15 seconds
cpu time 0.07 seconds
787! /* End PROC step */
788
789 /*Obtain values of all variables for the 1st 10 records*/
790
791 proc print data=test (obs=10); /* Begin PROC step */
792 run;
NOTE: PROCEDURE PRINT used:
real time 0.41 seconds
cpu time 0.29 seconds
792! /* End PROC step */
|
Contact: Charles Burchill
Telephone: (204) 789-3429
Manitoba Centre
for Health Policy
Department of Community Health Sciences,
University of Manitoba
4th floor Brodie Centre
408 - 727 McDermot Avenue
Winnipeg, Manitoba
R3E 3P5
Fax: (204) 789-3910
|