Task
|
Example Code
|
---|---|
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
a variable
Accumulate values
|
retain SumSec 5400; 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 variableFormat
a variable
|
label sumsec='Cumulative Total Seconds'; format sumsec comma6.; |
data research.drug1h(drop=placebo uric); set clinic.cltrials(drop=triglyc); if sex='M' then delete; if placebo='YES'; retain TestDate'22MAY2000'd; retain Days 30; days+1; length Retest $ 5; if cholesterol>190 then retest='YES'; else if 150<=cholesterol<=190 then retest='CHECK'; else if cholesterol<150 then retest='NO'; label retest='Perform Cholesterol Test 2?'; run;
proc print data=research.drug1h; run;
data research.drug1h(drop=placebo);
set clinic.cltrials(drop=triglycerides uricacid);
if placebo='YES';
run;