I've been banging my head for hours trying to find out where in my code this warning is coming from. It's preventing me from continuing since it kind of breaks SAS(I have to close and reopen SAS every time to get things working again). I suspect maybe I'm missing a ; or some sort of statement somewhere because I couldn't find any unclosed quotes. I also don't see where any macro variables could exceed the 262 char limit... I inherited this code from someone else before they left for paternity leave so I've been having to try and figure out what they did but their code isn't working right. If anyone can see what's wrong and help me fix this it'd be greatly appreciated.
%macro var_maker();*<==This is where you would add new criteria. Make sure it has a label otherwise it won't be included in the automated processing;
proc sql;
create table count_sums /* Note that I will need to include order count and refill count */
as select
MRN
,Group_Indicator
,Opioid_or_Benzo
,Report_Date
,sum(Init_fill_and_refills) as fill_refill_count
/* Criteria not combined with fills */
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <92 then 1 else 0 end) >= 1 /* spans 365 days, with the first quarter 92 days and all others 91 */
AND sum(case when 92 <= Report_Date - Ordering_Date_Time <183 then 1 else 0 end) >= 1
AND sum(case when 183 <= Report_Date - Ordering_Date_Time <274 then 1 else 0 end) >= 1
AND sum(case when 274 <= Report_Date - Ordering_Date_Time <365 then 1 else 0 end) >= 1
then 1 else 0 end as fills_all_quarters label "Orders in All Quarters"
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <183 then 1 else 0 end) >= 1 /* First period 183 days, second 182 */
AND sum(case when 183 <= Report_Date - Ordering_Date_Time <366 then 1 else 0 end) >= 1
then 1 else 0 end as fills_both_halves label "Orders in Both Halves"
%let i=3;
%do %while (&i <= 12);
/* Criteria combined with fills */
,case when sum(Init_fill_and_refills) < &i then 0
when sum(Init_fill_and_refills) >= &i then 1
else . end as fill_refill_count_&i label "&i Orders or More"
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <92 then 1 else 0 end) >= 1 /* spans 365 days, with the first quarter 92 days and all others 91 */
AND sum(case when 92 <= Report_Date - Ordering_Date_Time <183 then 1 else 0 end) >= 1
AND sum(case when 183 <= Report_Date - Ordering_Date_Time <274 then 1 else 0 end) >= 1
AND sum(case when 274 <= Report_Date - Ordering_Date_Time <365 then 1 else 0 end) >= 1
AND sum(Init_fill_and_refills) >= &i /* Adds in a fill count requirement */
then 1 else 0 end as fills_all_quarters_fill_ge_&i label "Orders in All Quarters AND &i Orders or More"
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <92 then 1 else 0 end) >= 1 /* spans 365 days, with the first quarter 92 days and all others 91 */
AND sum(case when 92 <= Report_Date - Ordering_Date_Time <183 then 1 else 0 end) >= 1
AND sum(Init_fill_and_refills) >= &i /* Adds in a fill count requirement */
then 1 else 0 end as fills_qneg_1n2_fill_ge_&i label "Orders in -1 and -2 Quarters AND &i Orders or More"
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <92 then 1 else 0 end) >= 1 /* spans 365 days, with the first quarter 92 days and all others 91 */
AND sum(Init_fill_and_refills) >= &i /* Adds in a fill count requirement */
then 1 else 0 end as fills_qneg_1_fill_ge_&i label "Orders in -1 Quarter AND &i Orders or More"
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <183 then 1 else 0 end) >= 1 /* First period 183 days, second 182 */
AND sum(case when 183 <= Report_Date - Ordering_Date_Time <366 then 1 else 0 end) >= 1
AND sum(Init_fill_and_refills) >= &i /* Adds in a fill count requirement */
then 1 else 0 end as fills_both_halves_fill_ge_&i label "Orders in Both Halves AND &i Orders or More"
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <183 then 1 else 0 end) >= 1 /* First period 183 days, second 182 */
AND sum(Init_fill_and_refills) >= &i /* Adds in a fill count requirement */
then 1 else 0 end as fills_halfneg_1_fill_ge_&i label "Orders in -1 Half AND &i Orders or More"
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <181 then 1 else 0 end) >= 1 /* First period 180 days, no 2nd */
AND sum(Init_fill_and_refills) >= &i /* Adds in a fill count requirement */
then 1 else 0 end as fills_last180_fill_ge_&i label "Orders in last 180 AND &i Orders or More"
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <121 then 1 else 0 end) >= 1 /* First period 120 days, no 2nd */
AND sum(Init_fill_and_refills) >= &i /* Adds in a fill count requirement */
then 1 else 0 end as fills_last120_fill_ge_&i label "Orders in last 120 AND &i Orders or More"
,case when sum(case when 0 <= Report_Date - Ordering_Date_Time <121 then 1 else 0 end) >= 1 /* First period 90 days, no 2nd */
AND sum(Init_fill_and_refills) >= &i /* Adds in a fill count requirement */
then 1 else 0 end as fills_last90_fill_ge_&i label "Orders in last 90 AND &i Orders or More"
%let i = %sysevalf(&i + 1);
%end;
from data3.analytic_file
group by Opioid_or_Benzo, Group_Indicator, MRN, Report_Date
;
quit;
title "Fill Counts by Opioid/Benzo and Group";
proc univariate data=count_sums;
var fill_refill_count;
histogram;
by Opioid_or_Benzo Group_Indicator;
run;
/* Checking 1-fill patients */
proc sql;
create table one_fill_patients
as select distinct a.*
from data3.analytic_file as a inner join count_sums as b
on a.MRN = b.MRN
where fill_refill_count = 1 /* Eliminates patients included in error */
;
quit;
%mend;
Hello @Leon27607,
The apostrophe in "won't" in the very first comment is the culprit. Never use comment statements (i.e. *...;) in macros. Write this comment in the form /* ... */ and the problem should vanish.
Hello @Leon27607,
The apostrophe in "won't" in the very first comment is the culprit. Never use comment statements (i.e. *...;) in macros. Write this comment in the form /* ... */ and the problem should vanish.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.