-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSAS9 Proc Report Example_Sanitized.sas
344 lines (275 loc) · 11 KB
/
SAS9 Proc Report Example_Sanitized.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
/* Project Title: Proc Report Example
Requesting Department: Internal
Requestor: XXXXXXXXXX
Origination Date: 9/19/2023
Requested Completion Date: 9/29/2023
Date received: 9/19/2023
Assigned Priority: High
Assigned Delivery Date: 9/29/2023
RDA_Project_number: XXXXXXXXXX
Assigned Analyst: Meagan Windler
Assigned Days: 2
Support Analyst:
Perc_Support:
Assigned Completion Date: 9/29/2023
Remarks: All pharmacy fills during 1st quarter of 2023. Summary on one tab broken out by
Company and network (Ascension St. John, Saint Francis, Other) and fill month.
Claim Detail on another tab. Include Women's health.
For summary tab include – Month, Company Network, # of scripts, total days supply,
Member Pay, CCOK Pay, and Total Allow
For detail tab include – Company, Network, claim number, member number, fill date,
days supply, dispensed quantity, ndc,*/
/****************************************************************/
/***** Setup *****/
/****************************************************************/
/* Clearing Work Library */
Proc Datasets nolist nodetails lib=Work kill;
Quit;
%Let Root = XXXXXXXXXX;
%Let Outpath=&Root\\HDA\RDA\mwindler\Proc Report Example\Output;
%Let analyst=MW;
%Let rda=XXXXXXXXXX;
%Let RprtDate = %Sysfunc(PutN(%Sysfunc(Today()),yymmddn8)) ;
%Let RunDate = %Sysfunc(PutN(%Sysfunc(Today()),mmddyys10)) ;
%Let SASAutos = &Root\HDA\Resources\SAS_Macros ;
Options SASAutos = (SASAutos,"&SASAutos") ;
Options XSync NoXWait MAUTOSOURCE ;
Option FmtSearch = (Work Formats) ;
/*Timeframe for services*/
%Let period_start = '01JAN2023'd;
%Let period_end = '31MAR2023'd;
/****************************************************************/
/***** Pharmacy Data Pull *****/
/****************************************************************/
*Establish variables for quicker data pulls;
%Let fill_vars=
buss_carr mbr_rgn rxclm rxclm_seq rev_paid_flg mbr_id date_fill
day_sup disp_quant ndc amt_mbr_pay amt_paid amt_tot;
%Let Network_SF='XXXXXXXXXX';
%Let Network_ASJ='XXXXXXXXXX','XXXXXXXXXX','XXXXXXXXXX';
*Data pull from CVSDATA.CVSRXDATA;
Data q1fills;
Format buss_carr mbr_rgn rxclm rxclm_seq rev_paid_flg mbr_id
date_fill day_sup disp_quant ndc amt_mbr_pay amt_paid amt_tot;
Set cvsdata.cvsrxdata (Keep=&fill_vars);
Where &period_start <= date_fill <= &period_end; Run;
*Data pull from CVSDATA.CVSWH for women's health fills;
Data q1fills_wh;
Format buss_carr mbr_rgn rxclm rxclm_seq rev_paid_flg mbr_id
date_fill day_sup disp_quant ndc amt_mbr_pay amt_paid amt_tot;
Set cvsdata.cvswh (Keep=&fill_vars);
Where &period_start <= date_fill <= &period_end; Run;
*Merge the two pharm pulls;
Data q1fills_merged;
Set q1fills q1fills_wh; Run;
*Select only paid claims;
Proc Sort Data=q1fills_merged;
By rxclm Descending rxclm_seq Descending rev_paid_flg; Run;
Data paid_q1fills;
Set q1fills_merged;
By rxclm;
If last.rxclm and rev_paid_flg > 0; Run;
*Adding company, network, and month_fill to dataset;
Data q1fills_2;
Set paid_q1fills;
bus_unit=substr(buss_carr,1,2);
If bus_unit = 'XXXXXXXXXX' then Company="CommunityCare XXXXXXXXXX";
Else if bus_unit = 'XXXXXXXXXX' then Company='CommunityCare XXXXXXXXXX';
Else if bus_unit in ('XXXXXXXXXX', 'XXXXXXXXXX') then Company='CommunityCareXXXXXXXXXX';
Else if bus_unit = 'XXXXXXXXXX' then Company='CommunityCare XXXXXXXXXX';
Else if buss_carr = 'XXXXXXXXXX' then Company='CommunityCare XXXXXXXXXX';
If mbr_rgn in (&Network_ASJ) then network = 'XXXXXXXXXX';
else if mbr_rgn in (&Network_SF) then network = 'XXXXXXXXXX';
else network = 'Other';
month_fill=Month(date_fill); Run;
*Creating dataset for summary tab;
Data summary;
Set q1fills_2 (Keep=company network month_fill day_sup amt_mbr_pay amt_paid amt_tot);
Fill_count= 1;
Run;
* Summarize claims by company, network, and fill month;
Proc Summary Data=summary nway missing;
Class month_fill company network;
Var fill_count day_sup amt_mbr_pay amt_paid amt_tot;
output out=q1fills_summary sum=; Run;
Data q1fills_summary_2 (Drop=_type_ _freq_);
Set q1fills_summary; Run;
Data q1fills_summary_3;
Set q1fills_summary_2;
fill_month = mdy(month_fill, 1, 2023);
Format fill_month monyy7.; Run;
*Detail report dataset;
Data q1fills_detail;
Set q1fills_2 (Keep=Company network rxclm mbr_id date_fill day_sup disp_quant ndc);
fill_date = put(date_fill, mmddyy10.);Run;
/****************************************************************/
/***** Macro Reports *****/
/****************************************************************/
*Macro for q1 fill summary tab;
%Macro RprtQ1FillSummary();
Title;
%Let Title1 = Pharmacy Fills for Q1 2023;
%Let Title2 = Summary By Company, Network, and Month;
Footnote;
Proc Report Data = q1fills_summary_3 nowindows missing
Style(Header) = {VerticalAlign = middle}
Style(Column) = {FontFamily = "Trebuchet MS" FontSize = 12pt};
Title1 j = l Height = 14pt Font = "Trebuchet MS" Bold Color = Black " &Title1";
Title2 j = l Height = 13pt Font = "Trebuchet MS" Bold Color = '#808080' " &Title2";
Column fill_month Company network fill_count day_sup amt_mbr_pay amt_paid amt_tot;
Define fill_month/Group 'Fill Month' order=data Style(column)=data[width=1000% tagattr='wrap:yes'];
Define company/Group 'Company' Style(column)=data[width=1000% tagattr='wrap:yes'];
Define network/Group 'Network' Style(column)=data[width=1000% tagattr='wrap:yes'];
Define fill_count/Analysis 'Total Scripts' Style(column)=data[width=1000% tagattr='wrap:yes'];
Define day_sup/Analysis 'Total Days Supply' Style(column)=data[width=1000% tagattr='wrap:yes'];
Define amt_mbr_pay/Analysis 'Total Member Pay' Style(column)=data[width=1000% tagattr='wrap:yes'];
Define amt_paid/Analysis 'Total CCOK Pay' Style(column)=data[width=1000% tagattr='wrap:yes'];
Define amt_tot/Analysis 'Total Allow Amount' Style(column)=data[width=1000% tagattr='wrap:yes'];
Break After fill_month / Summarize Style = {Background = #C8C8C8 Foreground = Black Font = ('Trebuchet MS',12pt,bold)};
Compute Before fill_month;
network='Subtotal'; Endcomp;
RBreak After / Summarize Style = {Background = #DBF5DC Foreground = Black Font = ('Trebuchet MS',12pt,bold)};
Compute after ;
network='Grand Total'; Endcomp;
Run; %Mend;
*Macro pharmacy fill detail tab;
%Macro RprtQ1FillsDetails();
Title;
%Let Title1 = Pharmacy Fills for Q1 2023;
%Let Title2 = Detail Page;
Footnote;
Proc Report Data = q1fills_detail nowindows missing
Style(Header) = {VerticalAlign = middle}
Style(Column) = {FontFamily = "Trebuchet MS" FontSize = 12pt};
Title1 j = l Height = 14pt Font = "Trebuchet MS" Bold Color = Black " &Title1";
Title2 j = l Height = 13pt Font = "Trebuchet MS" Bold Color = '#808080' " &Title2";
Column Company network rxclm mbr_id fill_date day_sup disp_quant ndc;
Define Company/Display 'Company';
Define network/Display 'Network';
Define rxclm/Display 'Claim Number';
Define mbr_id/Display 'Member Number';
Define fill_date/Display 'Fill Date';
Define day_sup/Display 'Days Supply';
Define disp_quant/Display 'Dispensed Quantity';
Define ndc/Display 'National Drug Code';
Run ; %Mend ;
/****************************************************************/
/***** Exporting Data *****/
/****************************************************************/
%Let RprtFileName = Pharmacy Training Assignment;
%Let PartOneWidths = 20, 20, 20, 20, 20, 20, 20;
%Let PartTwoWidths = 20, 20, 20, 20, 20, 20, 20, 20;
Options topmargin = .5in
bottommargin = .7in
leftmargin = .25in
rightmargin = .25in ;
ODS Path(Prepend) Work.Template(Update) ;
Proc Template ;
Define Style SummaryReport ;
Parent = Styles.Excel ;
Class Body /
BackGroundColor = White
FontFamily = "Trebuchet MS"
Fontsize = 12pt
Color = Black
;
Class SystemTitle /
BackGroundColor = White
FontFamily = "Trebuchet MS"
FontWeight = Bold
;
Class SystemFooter /
BackGroundColor = White
FontFamily = "Trebuchet MS"
FontSize = 12pt
;
Style CellContents /
FontFamily = "Trebuchet MS"
FontSize = 12pt
Color = Black
;
Style Header /
BackGroundColor = cx007852
FontFamily = "Trebuchet MS"
FontSize = 12pt
FontWeight = Bold
Color = White
;
Style Table /
FontFamily = "Trebuchet MS"
FontSize = 12pt
Color = Black
;
End ; Run ;
ODS _ALL_ Close ;
ODS Excel File = "%SuperQ(OutPath)\&RprtFileName &RprtDate..xlsx"
Style = SummaryReport
Options(
Row_Repeat = '10'
Frozen_Headers = '10'
Print_Footer = "%NRSTR(&L&11)&RDA - &Analyst %NRSTR(&C&11) Page %NRSTR(&P) of %NRSTR(&N) %NRSTR(&R&11) &rundate" /* Standard by Department policy */
Print_Footer_Margin = '.25'
Embed_Titles_Once = 'On'
Embedded_Titles = 'Yes'
Embedded_Footnotes = 'Yes'
GridLines = 'Off'
Row_Heights = '0,0,0,0,0,0,10'
Orientation = 'Landscape'
Center_Horizontal = 'no'
FitToPage = 'yes'
Pages_FitHeight = '9999'
Pages_FitWidth = '1'
Flow = 'Text'
Suppress_ByLines = 'ON'
Sheet_Interval = 'None'
) ;
ODS Excel
Options(
Sheet_Name = "Summary"
Absolute_Column_Width = "&PartOneWidths") ;
Proc GOptions ;/* Add logo */
Title ;
Footnote ;
GOptions iback = "&Root\HDA\Resources\Logos\Community Care Logo 856x282.jpg"
ImageStyle = Fit VSize = 0.8in HSize = 1.85in ; Run ;
Proc GSlide ; Run ;
%RprtQ1FillSummary; /* Call Proc Report */
/****************************************************************/
/***** Exporting Detail Data *****/
/****************************************************************/
/*Exporting detail data using ODS Tag Sets as it times out via ODS Excel*/
ods results=off;
ods tagsets.excelxp file="&Outpath\Pharmacy Training.xml"
/* Conforming to CCOK Communication Guidelines */
style = SaswebCCOKcg
options(
embedded_titles = 'yes'
embedded_footnotes = 'yes'
row_repeat = "5"
frozen_headers = '4'
print_footer = "%NRSTR(&L&11)&RDA - &analyst %NRSTR(&C&11) %NRSTR(&r&11)"
page_order_across = 'yes'
center_horizontal = 'yes'
gridlines = 'yes'
fittopage = 'yes'
pages_fitwidth = '1'
pages_fitheight = '1000'
orientation = 'portrait'
autofit_height = 'yes'
sheet_interval = 'proc'
zoom = "80"
absolute_column_width = '20,20,20,20,20');
/* Defining Sheet Name for Export */
ods tagsets.Excelxp options(sheet_name="Details");
/* Addding titles and footnotes */
Title1 "Pharmacy Fills for Q1 2023";
Title2 "Detail Page";
%RprtQ1FillsDetails() ;
title;
title2;
/* Closing ODS Excel */
ods tagsets.excelxp close;
ods results=on;
%XMLtoXLSX (&OutPath ,
%quote(Pharmacy Training) ,
1 ) ;