the ‘skip’ macro plagiarized from a paper by paul grant private healthcare systems, inc. given...

9
The ‘SKIP’ The ‘SKIP’ Macro Macro Plagiarized from a paper by Plagiarized from a paper by Paul Grant Paul Grant Private Healthcare Systems, Private Healthcare Systems, Inc. Inc. given at SUGI 23, Nashville, given at SUGI 23, Nashville, TN, 1998 TN, 1998

Upload: florence-woods

Post on 18-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The ‘SKIP’ Macro Plagiarized from a paper by Paul Grant Private Healthcare Systems, Inc. given at SUGI 23, Nashville, TN, 1998

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

Page 2: The ‘SKIP’ Macro Plagiarized from a paper by Paul Grant Private Healthcare Systems, Inc. given at SUGI 23, Nashville, TN, 1998

The ProblemThe Problem

You want to rerun a SAS program, without running certain sections of code.

Page 3: The ‘SKIP’ Macro Plagiarized from a paper by Paul Grant Private Healthcare Systems, Inc. given at SUGI 23, Nashville, TN, 1998

Two SolutionsTwo Solutions

/*...*/ style comments

For some procedures:

run cancel;

Page 4: The ‘SKIP’ Macro Plagiarized from a paper by Paul Grant Private Healthcare Systems, Inc. given at SUGI 23, Nashville, TN, 1998

<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>

Page 5: The ‘SKIP’ Macro Plagiarized from a paper by Paul Grant Private Healthcare Systems, Inc. given at SUGI 23, Nashville, TN, 1998

<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.

Page 6: The ‘SKIP’ Macro Plagiarized from a paper by Paul Grant Private Healthcare Systems, Inc. given at SUGI 23, Nashville, TN, 1998

<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

Page 7: The ‘SKIP’ Macro Plagiarized from a paper by Paul Grant Private Healthcare Systems, Inc. given at SUGI 23, Nashville, TN, 1998

<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

Page 8: The ‘SKIP’ Macro Plagiarized from a paper by Paul Grant Private Healthcare Systems, Inc. given at SUGI 23, Nashville, TN, 1998

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>

Page 9: The ‘SKIP’ Macro Plagiarized from a paper by Paul Grant Private Healthcare Systems, Inc. given at SUGI 23, Nashville, TN, 1998

The EndThe End