Task
|
Statement to Use
|
---|---|
Reference a SAS data
library
Reference an external
file
|
libname clinic 'c:usersmaydata'; filename tests 'c:users mill.dat'; |
Name a SAS data set
Identify an external
file
Describe raw data
|
data clinic.stress; infile tests obs=10; input ID $ 1-4 Name $ 6-25 ...; |
Subset data
|
if resthr<70 then delete; if tolerance='D'; |
Drop unwanted variables
|
drop timemin timesec; |
Create or modify a variable
|
TotalTime=(timemin*60)+timesec; |
Initialize and retain
variable
|
retain SumSec 5400; |
Accumulate values
|
sumsec+totaltime; |
Specify a variable's
length
|
length TestLength $ 6; |
Execute statements conditionally
|
if totaltime>800 then TestLength='Long'; else if 750<=totaltime<=800 then TestLength='Normal'; else if totaltime<750 then TestLength='Short'; |
Label a variable
|
label sumsec='Cumulative Total Seconds (+5,400)'; |
Format a variable
|
format sumsec comma6.; |
Execute the DATA step
|
run; |
List the data
|
proc print data=clinic.stress label; |
Execute the final program
step
|
run; |
data clinic.stress; infile tests; input ID $ 1-4 Name $ 6-25 RestHR 27-29 MaxHR 31-33 RecHR 35-37 TimeMin 39-40 TimeSec 42-43 Tolerance $ 45; if resthr<70 then delete; if tolerance='D'; drop timemin timesec; TotalTime=(timemin*60)+timesec; retain SumSec 5400; sumsec+totaltime; length TestLength $ 6; if totaltime>800 then testlength='Long'; else if 750<=totaltime<=800 then testlength='Normal'; else if totaltime<750 then TestLength='Short'; label sumsec='Cumulative Total Seconds (+5,400)'; format sumsec comma6.; run;
proc print data=clinic.stress label; run;