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: Clinical - Log
The "NOTE: Invalid data..." in the log below indicates a problem with the
values for the VISIT variable for 2 observations. Further investigation
found values missing for two observations, as per the PROC PRINT in
the output.
131 ***********************************************;
132 * f=My SAS Files\sasmanual\clinical_cr *;
133 * *;
134 *This file creates the "clinical" SAS data *;
135 *set. Code is included for saving it as a *;
136 *permanent or temporary SAS data set: *;
137 * 1) Permanent - ensure an asterisk begins the*;
138 * statement "data clinical" and that *;
139 * no asterisk precedes *;
140 * "data mydir.clinical" *;
141 * 2) Temporary - ensure an asterisk precedes *;
142 * the statement "data mydir.clinical" *;
143 * and that no asterisk precedes "data *;
144 * clinical". Also, the libname *;
145 * statement is not needed. *;
146 ***********************************************;
147
148 options ls=min;
149
150 %include 'c:\My Documents\My SAS
150! Files\sasmanual\formats\clinical_fmt.sas';
NOTE: Format $GENDER has been output.
NOTE: Format $DXCODES has been output.
NOTE: Format $YESNO has been output.
NOTE: PROCEDURE FORMAT used:
real time 0.60 seconds
180
181 libname mydir 'c:\My Documents\My SAS Files\sasmanual\data'
181! ;
NOTE: Libref MYDIR was successfully assigned as follows:
Engine: V7
Physical Name: c:\My Documents\My SAS Files\sasmanual\data
182 filename clinread 'c:\My Documents\My SAS
182! Files\sasmanual\data\clinical.dat';
183
184 data mydir.clinical; /* SAVE AS PERMANENT SAS DATA SET*/
185 *data clinical; /* SAVE AS TEMPORARY SAS DATA SET*/
186 infile clinread;
187 input @1 id $3.
188 @4 gender $1.
189 @5 dob MMDDYY6.
190 @11 visit MMDDYY6.
191 @17 prim_dx $2.
192 @19 sec_dx $2.
193 @21 hr 3.
194 @24 sbp 3.
195 @27 dbp 3.
196 @30 vitamins $1.
197 @31 pregnant $1.;
198
199 LABEL id = 'Pt. Number'
200 gender = 'Gender'
201 dob = 'Date of Birth'
202 visit = 'Visit Date'
203 prim_dx = 'Primary DX'
204 sec_dx = 'Secondary DX'
205 hr = 'Heart Rate'
206 sbp = 'Systolic Blood Pressure'
207 dbp = 'Diastolic Blood Pressure'
208 vitamins = 'Pt. Taking Vitamins?'
209 pregnant = 'Is Pt. Pregnant?';
210
211 run;
NOTE: The infile CLINREAD is:
File Name=c:\My Documents\My SAS
Files\sasmanual\data\clinical.dat,
RECFM=V,LRECL=256
NOTE: Invalid data for visit in line 12 11-16.
RULE: ----+----1----+----2----+----3----+----4----+----5----
12 324F01011075119506 08620010010 31
id=324 gender=F dob=18263 visit=. prim_dx=06 sec_dx= hr=86
sbp=200 dbp=100 vitamins=1 pregnant=0 _ERROR_=1 _N_=12
NOTE: Invalid data for visit in line 13 11-16.
13 012F100908760195030809018409800 31
id=012 gender=F dob=17814 visit=. prim_dx=03 sec_dx=08 hr=90
sbp=184 dbp=98 vitamins=0 pregnant=0 _ERROR_=1 _N_=13
NOTE: 34 records were read from the infile CLINREAD.
The minimum record length was 31.
The maximum record length was 31.
NOTE: The data set MYDIR.CLINICAL has 34 observations and 11
variables.
NOTE: DATA statement used:
real time 1.20 seconds
212
213 proc contents data=mydir.clinical;
214 run;
NOTE: PROCEDURE CONTENTS used:
real time 2.62 seconds
215
216 proc print data=mydir.clinical;
217 run;
NOTE: PROCEDURE PRINT used:
real time 0.22 seconds
218
219 proc print data=mydir.clinical;
220 format prim_dx sec_dx $dxcodes.
221 dob visit mmddyy8.
222 gender $gender.
223 vitamins pregnant $yesno.;
224 run;
NOTE: PROCEDURE PRINT used:
real time 0.33 seconds
|
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
|