Upload
jrhampt
View
255
Download
1
Embed Size (px)
Citation preview
04/15/23 2
IntroductionUSE:• Simple organization techniques• Macro variables• Parameterized macros • Appropriate documentation
TO:• Reduce hard coding• Reduce code volume• Make regularly updated values easy to find
04/15/23 3
Steps 1-2: Chunking & Numbering
• Break up large processes into individual programs
• Number programs in order of process flow
04/15/23 5
Step 3: Initial Setup• Create an initial setup program
for:– Libnames– Remote sessions– Macro variables– System options
04/15/23 7
Step 4: Final Cleanup• Create a final cleanup program to:
– Download files on remote server– Delete interim files no longer needed– Create final table listing and export
“data dictionary” to Excel– Use data dictionary to identify problems
•Unexpected row counts•Unnecessarily long fields
04/15/23 9
Step 5: Macro Variables• Use macro variables for date selection
criteria:
…where ben_feat_eff_dt <=”&startdate”d and ben_feat_can_dt>”&startdate”d;
…Case when HRA_Month_Start = 1 Then &yearmonth + HRA_Month_Start Else &yearlastmonth +
HRA_Month_Start End as HRA_Prog_Yr_Start,…
04/15/23 10
Step 6: Macro Variables• Use macro variables for file
names:
Create Table qry_Ben_Feat_&year as…
Proc Download Data = WHP.Internal_EPop_&year OUT=HRA.Internal_EPop_&year;
Libname PPO “/projects/hedis/ppo&year”;
04/15/23 11
Step 7: Macro Variables• Use macro variables for frequently updated/referenced lists:
%let markets = %str('WA','OR','CA','CO','TN','FL','SC','MD','DC','OH','NJ','NY','CT'); /*eValu8 markets*/
%let diabetes = %str('25000','25001','25002','25003','25010','25011','25012','25013','25020','25021','25022','25023','25030','25050','25051','25052','25053','25060','25061','25062','25063','25070','25071','25072','25073','25080','25031','25032','25033','25040','25041','25042','25043','25081','25082','25083','25090','25091','25092','25093');/*diabetes diagnosis codes, used in measures 1,3,14,16*/
SELECT code INTO: opnaiprev separated by '","' /*outpatient, non-acute inpatient revenue proc codes*/
FROM ref.ectWHERE description in('outpatient','nonacute_inpatient')AND typeofcode='RevCode'AND tablename='CDC_C';
04/15/23 12
Step 7: (continued)• Code is shorter • Easier to understand• Can update all in one place
WHERE svc_dt BETWEEN "01jan&yearp"d AND "31dec&year"d /*current year or year prior*/
AND (diag_cd1 IN (&diagcd) OR diag_cd2 IN (&diagcd) OR diag_cd3 IN (&diagcd))/*primary or secondary diagnosis code*/
AND (proc_cd IN("&aipedcpt")/*acute inpatient or ED cpt codes*/
OR (proc_cd IN("&aipedrev")
04/15/23 13
Step 8: Parameterized Macros
• Analyze processes for similarities• Identify re-usable pieces of code• Convert to parameterized
macros• Reduce code volume
04/15/23 14
Step 8: Analysis
Measure Numerator Exclusions
1,3,10,14
include discharges with principal diagnosis code specified:diabetes short term complicationsdiabetes long term complicationshypovolemiauncontrolled diabetes transfers
7*,8,13
include discharges with principal diagnosis code specified: hypertensionCHFangina
transferscardiac procedure codes in any field*For 7 only, also exclude kidney disease diagnoses if accompanied by hemodialysis procs
11,12
include discharges with principal diagnosis code specified: bacterial pneumoniaUTI
transfersimmunocompromised state proc codesimmunocompromised state diagnoses*For 11, also exclude anemia principal or secondary diagnoses*For 12, also exclude principal or secondary kidney disorder diagnoses
04/15/23 15
Step 8: Parameterized Macro%macro transfer(filename=)/STORE SOURCE; /*identify and delete transfers from
numerator*/
CREATE TABLE &filename._TRANS AS
SELECT B.conf_id, B.admit_dt, A.disch_dt
FROM PQI.&filename A
JOIN PQI.&filename B ON A.rhmo=B.rhmo AND A.bkey=B.bkey
AND A.disch_dt BETWEEN B.admit_dt AND intnx('DAY',B.admit_dt,-1)/*re-admitted within 24 hours of discharge date*/
WHERE A.conf_id <> B.conf_id
AND A.src_sys_prov_id <> B.src_sys_prov_id /*transferred from different facility*/
;
DELETE
FROM PQI.&filename
WHERE conf_ID IN
(SELECT conf_id FROM &filename._TRANS)
;
%mend transfer;
04/15/23 17
Steps 9-10: Documentation
• Comment code• Use program headers
– Program name– Developer name– Date created– Purpose– Update information
• Programmer name• Date modified• Reason for modification
– Input/output tables
04/15/23 18
Conclusion1. Break up large processes into smaller steps2. Number programs in order of process flow3. Create initial setup program4. Create final cleanup program5. Use macro variables for date selection criteria6. Use macro variables for file names7. Use macro variables for long lists that need
frequent updating and/or are referenced frequently
8. Use parameterized macros for similar processes9. Document using comments10.Document using program headers
04/15/23 19
References• SAS Institute Inc. 2009. SAS 9.2 Macro
Language Reference. Cary, NC: SAS Institute, Inc.
• Patridge, C. Best Practices: Using SAS Effectively/Efficiently. HASUG presentation 2/24/2011.
• Rhodes, D. If You Have Programming Standards, Please Raise Your Hand: An Everyman’s Guide. http://www.nesug.org/Proceedings/nesug10/ma/ma10.pdf (5/31/2011).
04/15/23 20
AcknowledgementSAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.
Other brand and product names are registered trademarks or trademarks of their respective companies.