BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Leon27607
Fluorite | Level 6

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;
1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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.

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

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.

Leon27607
Fluorite | Level 6
Ah, thanks. I couldn't figure it out because it seemed like the comment was still correct(everything within was still green, and text outside was not).

sas-innovate-2024.png

 

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

 

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 710 views
  • 1 like
  • 2 in conversation