I am trying to get the difference in days between dates (char $10.) and merging two tables that are sorted by id. I'm doing a HEDIS and in the end there has to be a numerator and denominator to get a percentage. This is part of the numerator portion so I'm trying to flag all the conditions that meet what should be in the numerator:
22 GOPTIONS ACCESSIBLE;
23 DATA NUMERATOR1;
24 MERGE denom_final (in=a)
25 numerator (in=b) ;
26 DIF_DAYS=intck('day',input(ddate,yymmdd10.), input(edate,yymmdd10.));
27 if a;
28 if b then condition = "aaa" and DATEDIF <= '14' then Followup='1';
____
388
202
ERROR 388-185: Expecting an arithmetic operator.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
29 ELSE IF CONDITION = "hhh" AND DATEDIF <= '7' THEN Followup='1';
30 ELSE IF CONDITION = "ccc" AND DATEDIF <= '14' THEN Followup='1';
31 ELSE IF CONDITION = "sss" AND DATEDIF <= '14' THEN Followup='1';
32 ELSE IF CONDITION = "ddd" AND DATEDIF <= '30' THEN Followup='1';
33 ELSE IF CONDITION = "ooo" AND DATEDIF <= '30' THEN Followup='1';
34 Denom = '1';
35 RUN;
if b then condition = "aaa" and DATEDIF <= '14' then Followup='1';
This statement is incorrect, syntax wise.
What are you trying to do here? Are both conditions required?
This may possibly be what you need:
if b & DIF_DAYS <= 14 then do;
Followup=1;
condition = 'aaa';
end;
@bhca60 wrote:
I am trying to get the difference in days between dates (char $10.) and merging two tables that are sorted by id. I'm doing a HEDIS and in the end there has to be a numerator and denominator to get a percentage. This is part of the numerator portion so I'm trying to flag all the conditions that meet what should be in the numerator:
22 GOPTIONS ACCESSIBLE; 23 DATA NUMERATOR1; 24 MERGE denom_final (in=a) 25 numerator (in=b) ; 26 DIF_DAYS=intck('day',input(ddate,yymmdd10.), input(edate,yymmdd10.)); 27 if a; 28 if b then condition = "aaa" and DATEDIF <= '14' then Followup='1'; ____ 388 202 ERROR 388-185: Expecting an arithmetic operator. ERROR 202-322: The option or parameter is not recognized and will be ignored. 29 ELSE IF CONDITION = "hhh" AND DATEDIF <= '7' THEN Followup='1'; 30 ELSE IF CONDITION = "ccc" AND DATEDIF <= '14' THEN Followup='1'; 31 ELSE IF CONDITION = "sss" AND DATEDIF <= '14' THEN Followup='1'; 32 ELSE IF CONDITION = "ddd" AND DATEDIF <= '30' THEN Followup='1'; 33 ELSE IF CONDITION = "ooo" AND DATEDIF <= '30' THEN Followup='1'; 34 Denom = '1'; 35 RUN;
Is DIF_DAYS a different variable than DATEDIF?
You are treating DATEDIF as character (compared to '14' quotes means character).
You have a several issues most likely.
Fix your mistakes one at a time and go through them in ORDER. Start with the dates and then go down, otherwise, they cause more issues later on.
DATA NUMERATOR1;
MERGE denom_final (in=a)
numerator (in=b) ;
DIF_DAYS=intck('day',input(ddate,yymmdd10.), input(edate,yymmdd10.));
run;
Do it in stages.
post the log from above to make sure it works correctly first.
Below is how I came up with ddate as a variable:
if missing(input(dischdate,yymmdd10.))then ddate= input(edate,yymmdd10.);
else ddate= input(dischdate,yymmdd10.);
So now, I've been trying to get the number of days between ddate and edate since my data is a mix of inpatient and outpatient data and outpatient data does not have dischdate so the edate will replace that if blank.
If that step ran correctly, then ddate is not a character variable as specified in your initial post. In that case you do not need to use the INPUT function in the INTCK function.
@bhca60 wrote:
Below is how I came up with ddate as a variable:
if missing(input(dischdate,yymmdd10.))then ddate= input(edate,yymmdd10.);
else ddate= input(dischdate,yymmdd10.);
So now, I've been trying to get the number of days between ddate and edate since my data is a mix of inpatient and outpatient data and outpatient data does not have dischdate so the edate will replace that if blank.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.