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

Can someone look at this portion of my code below; I'm getting the following errors. I have been at this all morning and cannot get the code to run. Thank you in advance for any advice  

Lisa_Sessions_0-1637256928148.png

intck('month', input('Appointment Effective Date'n, anydtdte10.), input('Appointment Expiration Date'n, anydtdte10.)) as month_dif,
case
when calculated month_dif lt 36 then "Presumed Correct"
when calculated month_dif ge 37 then "Create New Start Date"
end as 'new_start_dt_id_1'n,
case
when calculated month_dif ge 37 then intnx('month', 'Appointment Expiration Date'n, -24, 's')
end as 'new_start_dt'n format=date9.,
case
when calculated 'new_start_dt'n ge today() then "Unknown"
else "" end as 'future_dt_id'n

 

1 ACCEPTED SOLUTION

Accepted Solutions
LMSSAS
Quartz | Level 8
Reeza - Thank you for the response. This is my first time posting in the SAS community and am not sure what is too much and not enough. Below the Log I also posted the full query

proc sql;
36 create table Inactive_DFS as
37 Select
38 'Licensee Name'n,
39 'License Number'n,
40 input('Appointment Effective Date'n, anydtdte10.) AS 'Appointment Effective Date'n FORMAT=DATE9.,
41 input('Appointment Expiration Date'n, anydtdte10.) AS 'Appointment Expiration Date'n FORMAT=DATE9.,
42 input('Appointment Status Date'n, anydtdte10.) AS 'Appointment Status Date'n FORMAT=DATE9.,
43 'Appointing Entity Number'n,
44 'Appointment TYCL number'n,
45 NPN Number,
______
22
46 intck('month', input('Appointment Effective Date'n, anydtdte10.), input('Appointment Expiration Date'n, anydtdte10.))
_ _ _
79 79 79
200 200
46 ! as month_dif,
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, ',', -, '.', /, <, <=, <>, =, >, >=, ?, AND, AS,
CONTAINS, EQ, EQT, FROM, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.

ERROR 79-322: Expecting a ).
ERROR 200-322: The symbol is not recognized and will be ignored.

47
48 case
49 when calculated month_dif lt 36 then "Presumed Correct"
____
22
76
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, (, ',', '.', ANSIMISS, AS, CROSS, EXCEPT, FULL, GROUP,
HAVING, INNER, INTERSECT, JOIN, LEFT, NATURAL, NOMISS, ORDER, OUTER, RIGHT, UNION, WHERE.

ERROR 76-322: Syntax error, statement will be ignored.

50 when calculated month_dif ge 37 then "Create New Start Date"
51 end as 'new_start_dt_id_1'n,
52 case
53 when calculated month_dif ge 37 then intnx('month', 'Appointment Expiration Date'n, -24, 's')
54 end as 'new_start_dt'n format=date9.,
55 case
56 when calculated 'new_start_dt'n ge today() then "Unknown"
57 else "" end as 'future_dt_id'n
58
59 From INACTIVE_06020_05687_87022_33461
60 where NPN Number in (&NATL_PDCR_NB.)
61 ;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
62 Quit;
NOTE: The SAS System stopped processing this step b

proc sql;
create table Inactive_DFS as
Select
'Licensee Name'n,
'License Number'n,
input('Appointment Effective Date'n, anydtdte10.) AS 'Appointment Effective Date'n FORMAT=DATE9.,
input('Appointment Expiration Date'n, anydtdte10.) AS 'Appointment Expiration Date'n FORMAT=DATE9.,
input('Appointment Status Date'n, anydtdte10.) AS 'Appointment Status Date'n FORMAT=DATE9.,
'Appointing Entity Number'n,
'Appointment TYCL number'n,
NPN Number,
intck('month', input('Appointment Effective Date'n, anydtdte10.), input('Appointment Expiration Date'n, anydtdte10.)) as month_dif,
case
when calculated month_dif lt 36 then "Presumed Correct"
when calculated month_dif ge 37 then "Create New Start Date"
end as 'new_start_dt_id_1'n,
case
when calculated month_dif ge 37 then intnx('month', 'Appointment Expiration Date'n, -24, 's')
end as 'new_start_dt'n format=date9.,
case
when calculated 'new_start_dt'n ge today() then "Unknown"
else "" end as 'future_dt_id'n

From INACTIVE_06020_05687_87022_33461
where NPN Number in (&NATL_PDCR_NB.)
;
Quit;

View solution in original post

10 REPLIES 10
Reeza
Super User
Can you show the actual log instead of just the error screenshot?
The log is usually more informative.

Also, please include the whole query, not just the portion.
LMSSAS
Quartz | Level 8
Reeza - Thank you for the response. This is my first time posting in the SAS community and am not sure what is too much and not enough. Below the Log I also posted the full query

proc sql;
36 create table Inactive_DFS as
37 Select
38 'Licensee Name'n,
39 'License Number'n,
40 input('Appointment Effective Date'n, anydtdte10.) AS 'Appointment Effective Date'n FORMAT=DATE9.,
41 input('Appointment Expiration Date'n, anydtdte10.) AS 'Appointment Expiration Date'n FORMAT=DATE9.,
42 input('Appointment Status Date'n, anydtdte10.) AS 'Appointment Status Date'n FORMAT=DATE9.,
43 'Appointing Entity Number'n,
44 'Appointment TYCL number'n,
45 NPN Number,
______
22
46 intck('month', input('Appointment Effective Date'n, anydtdte10.), input('Appointment Expiration Date'n, anydtdte10.))
_ _ _
79 79 79
200 200
46 ! as month_dif,
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, ',', -, '.', /, <, <=, <>, =, >, >=, ?, AND, AS,
CONTAINS, EQ, EQT, FROM, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.

ERROR 79-322: Expecting a ).
ERROR 200-322: The symbol is not recognized and will be ignored.

47
48 case
49 when calculated month_dif lt 36 then "Presumed Correct"
____
22
76
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, (, ',', '.', ANSIMISS, AS, CROSS, EXCEPT, FULL, GROUP,
HAVING, INNER, INTERSECT, JOIN, LEFT, NATURAL, NOMISS, ORDER, OUTER, RIGHT, UNION, WHERE.

ERROR 76-322: Syntax error, statement will be ignored.

50 when calculated month_dif ge 37 then "Create New Start Date"
51 end as 'new_start_dt_id_1'n,
52 case
53 when calculated month_dif ge 37 then intnx('month', 'Appointment Expiration Date'n, -24, 's')
54 end as 'new_start_dt'n format=date9.,
55 case
56 when calculated 'new_start_dt'n ge today() then "Unknown"
57 else "" end as 'future_dt_id'n
58
59 From INACTIVE_06020_05687_87022_33461
60 where NPN Number in (&NATL_PDCR_NB.)
61 ;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
62 Quit;
NOTE: The SAS System stopped processing this step b

proc sql;
create table Inactive_DFS as
Select
'Licensee Name'n,
'License Number'n,
input('Appointment Effective Date'n, anydtdte10.) AS 'Appointment Effective Date'n FORMAT=DATE9.,
input('Appointment Expiration Date'n, anydtdte10.) AS 'Appointment Expiration Date'n FORMAT=DATE9.,
input('Appointment Status Date'n, anydtdte10.) AS 'Appointment Status Date'n FORMAT=DATE9.,
'Appointing Entity Number'n,
'Appointment TYCL number'n,
NPN Number,
intck('month', input('Appointment Effective Date'n, anydtdte10.), input('Appointment Expiration Date'n, anydtdte10.)) as month_dif,
case
when calculated month_dif lt 36 then "Presumed Correct"
when calculated month_dif ge 37 then "Create New Start Date"
end as 'new_start_dt_id_1'n,
case
when calculated month_dif ge 37 then intnx('month', 'Appointment Expiration Date'n, -24, 's')
end as 'new_start_dt'n format=date9.,
case
when calculated 'new_start_dt'n ge today() then "Unknown"
else "" end as 'future_dt_id'n

From INACTIVE_06020_05687_87022_33461
where NPN Number in (&NATL_PDCR_NB.)
;
Quit;
Reeza
Super User

NPN Number needs the quotes and N as well, ie

'NPN Number'n

EDIT: note this is in more than one place in your code so you need to fix all of them.

LMSSAS
Quartz | Level 8
Thank you, I appreciate it. When I make your suggested change, I get the following errors all referencing the below where staement: I went through the intck statement and changed the 'lt' and 'ge' to < or > and still get the same error. DO you have any recommendation for this?

where 'NPN Number'n in (&NATL_PDCR_NB.)

ERROR: Function INTNX requires a numeric expression as argument 2.
ERROR: Character expression requires a character format.
ERROR: Expression using greater than or equal (>=) has components that are of different data types.
Reeza
Super User
It was easy to find that first error because SAS underlined it.
If you post the whole log it makes it very easy to see exactly where the error is.

I suspect it's here:
when calculated month_dif ge 37 then intnx('month', 'Appointment Expiration Date'n, -24, 's')

You need to convert it as you did in the INTCK calculations or add the key word CALCULATED to use the newly converted variable.

Appointment Expiration date isn't a date as you convert it earlier

LMSSAS
Quartz | Level 8

 I will make sure moving forward that I copy the log for every new error and question. 

Thank you again for your time today !!!

Kurt_Bremser
Super User

And when you post logs, use this button:

Bildschirmfoto 2020-04-07 um 08.32.59.jpg

This will keep the horizontal position of markers.

The "little running man" next to it is for SAS code, it provides coloring similar to the Enhanced Editor.

LMSSAS
Quartz | Level 8
Thank you, I will use these.
i appreciate the inforamtion
Reeza
Super User
And just a last note, if you're working with an imported file, it's a good idea to set the following options so that you don't have spaces in the names. It makes life easier.

option validvarname=v7;

The default in Studio is Any which allows spaces in names but makes it a pain to work with.
LMSSAS
Quartz | Level 8
Thank you for this!!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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
  • 10 replies
  • 1187 views
  • 3 likes
  • 3 in conversation