BookmarkSubscribeRSS Feed
bhca60
Quartz | Level 8

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;
9 REPLIES 9
Reeza
Super User
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;

 

bhca60
Quartz | Level 8
yes both conditions are required for each of the 6 conditions (aaa, ccc, hhh...etc.) and they all equal 1 because in the end they will be added up to give a number for the numerator which will then be divided by a denominator number.
bhca60
Quartz | Level 8
The Do statement seems to work as it did populate the followup=1 column but I am having issues with the dif_days column and getting a Note about it:

26 DIF_DAYS=intck('day', input(ddate,yymmdd10.), input(edate,yymmdd10.));
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
26:32
NOTE: Invalid argument to function INPUT at line 26 column 26.
Reeza
Super User

Is DIF_DAYS a different variable than DATEDIF?

You are treating DATEDIF as character (compared to '14' quotes means character).

bhca60
Quartz | Level 8
I forgot to change those to dif_days but i still get the same error even when changing it to dif_days from datedif.
Reeza
Super User

You have a several issues most likely.

 

  • Missing dates is a possibility in INTCK
  • Referring to variables with incorrect names
  • Referring to variables with incorrect types, ie numeric versus character - '14', '7'
  • Assigning variables that should be numeric character types, ie followup='1'; Why do you want followup to be a character variable? If you don't plan to do any math on this variable that's fine though.
  • Incorrect syntax on an IF statement. 

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.

 

Reeza
Super User
        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.

bhca60
Quartz | Level 8

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.

Reeza
Super User

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 1019 views
  • 0 likes
  • 2 in conversation