Hi, I am looking at the SAS CSV USA-TSA Claim Data and I am getting this error: I am asked to create a column called Date_Issues where I track if there is an incorrect or unexpected formatting of the dates. It says that I should flag the date issues if either of the two date columns, Incident_Date or Date_Received, are outside the date range 2002-2017, or if Incident_Date>Date_Received. However, I am getting this error message when I do the inequality test:
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 data work.tsa_adjust;
70 set work.tsa_claims;
71 format Date_Received Incident_Date date9.;
72 length Claim_Site Claim_Type Disposition $ 100;
WARNING: Length of character variable Claim_Site has already been set.
Use the LENGTH statement as the very first statement in the DATA STEP to declare the length of a character variable.
WARNING: Length of character variable Claim_Type has already been set.
Use the LENGTH statement as the very first statement in the DATA STEP to declare the length of a character variable.
WARNING: Length of character variable Disposition has already been set.
Use the LENGTH statement as the very first statement in the DATA STEP to declare the length of a character variable.
73 if (Claim_Site in('-' '') or Claim_Site=.) then Claim_Site='Unknown';
74 if (Disposition in('-' '') or Disposition=.) then Disposition='Unknown';
75 if (Claim_Type in('-' '') or Claim_Type=.) then Claim_Type='Unknown';
76 if (Incident_Date=.) or (Incident_Date<'01JAN2002'd or Incident_Date>'31DEC2017'd))
_
22
200
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, ;, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT,
IN, LE, LT, MAX, MIN, NE, NG, NL, NOT, NOTIN, OR, THEN, ^, ^=, |, ||, ~, ~=.
ERROR 200-322: The symbol is not recognized and will be ignored.
77 then Date_Issues='Needs Review';
78 if (Date_Received=.) or (Date_Received<'01JAN2002'd or Date_Received>'31DEC2017'd))
_
22
200
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, ;, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT,
IN, LE, LT, MAX, MIN, NE, NG, NL, NOT, NOTIN, OR, THEN, ^, ^=, |, ||, ~, ~=.
ERROR 200-322: The symbol is not recognized and will be ignored.
79 then Date_Issues='Needs Review';
80 if (Incident_Date>Date_Received) then Date_Issues='Needs Review';
The character that is underlined is right paren ). SAS is listing all the things that it "allows" in the context and ) is not in the list.
Remove the ) right paren and see what you get.
It should be flagging the extra ) in the statement and not the date literal.
46 data _null_; 47 if (Incident_Date=.) or (Incident_Date<'01JAN2002'd or Incident_Date>'31DEC2017'd)) - 22 200 ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, ;, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOT, NOTIN, OR, THEN, ^, ^=, |, ||, ~, ~=. ERROR 200-322: The symbol is not recognized and will be ignored. 48 then Date_Issues='Needs Review'; 49 run;
But I was able to get SAS into a state where it did flag the date literal as an error.
825 data _null_; 826 if (Incident_Date=.) or (Incident_Date<'01JAN2002'd or Incident_Date>'31DEC2017'd)) - 390 200 76 ERROR 390-185: Expecting an relational or arithmetic operator. ERROR 200-322: The symbol is not recognized and will be ignored. ERROR 76-322: Syntax error, statement will be ignored. 827 then Date_Issues='Needs Review'; 828 run;
Not sure if it was because of some hidden character I copied from your example code or some other previous syntax errors I had made in the same SAS session.
But starting a new SAS session got it back to normal behavior.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.