the ‘skip’ macro plagiarized from a paper by paul grant private healthcare systems, inc. given...
TRANSCRIPT
The ‘SKIP’ MacroThe ‘SKIP’ Macro
Plagiarized from a paper byPlagiarized from a paper by
Paul Grant Paul GrantPrivate Healthcare Systems, Inc.Private Healthcare Systems, Inc.
given at SUGI 23, Nashville, TN, 1998given at SUGI 23, Nashville, TN, 1998
The ProblemThe Problem
You want to rerun a SAS program, without running certain sections of code.
Two SolutionsTwo Solutions
/*...*/ style comments
For some procedures:
run cancel;
<more SAS code to execute>
/*
data ages;
set demog;
agenow = (today()-dob)/365.25;
studyage = (studystrt-dob)/365.25;
run;
*/
proc print data=ages;
var patientid agenow studyage;
run cancel;
data ages;
set ages;
studytime = studystop - studystart;
run;
<more SAS code to execute>
<more SAS code to execute>
/*
data ages;
set demog;
/* Calculate the patient’s current age. */
agenow = (today()-dob)/365.25;
/* Calculate the patient’s age at study start. */
studyage = (studystart-dob)/365.25;
run;
*/
<more SAS code to execute>
Duh-o! I already have comments.Duh-o! I already have comments.
<more SAS code to execute>
%macro skip;data ages; set demog; /* Calculate the patient’s current age. */ agenow = (today()-dob)/365.25; /* Calculate the patient’s age at study start. */ studyage = (studystart-dob)/365.25;run;%mend skip;
<more SAS code to execute>
Solution: The SKIP macroSolution: The SKIP macro
<more SAS code to execute>
%macro skip;data ages; set demog; agenow = (today()-dob)/365.25; studyage = (studystrt-dob)/365.25;run;%mend skip;
proc print data=ages; var patientid agenow studyage;run;
%macro skip;data ages; set ages; studytime = studystop - studystart;run;%mend skip;
<more SAS code to execute>
SKIP can be repeatedSKIP can be repeated
Options NOSOURCEOptions NOSOURCE
If the skipped code is very long, you may want to prevent it from being printed to your SAS log.
<more SAS code to execute>
options nosource;
%macro skip;
data ages;
. . .
run;
%mend skip;
options source;
<more SAS code to execute>
The EndThe End