BookmarkSubscribeRSS Feed
Anuashla
Calcite | Level 5

Hello,

 

Referrring to the code below, I have to create a column 'calendar_date' which is the date in the column 'Start_date' incremented by the months in corresponding 'exposure' column. The program gives me an error which is mentioned below:

 

CODE:

PROC SQL;
CREATE TABLE CONTRACTS_VIN AS
SELECT * FROM EXPOSURE_CONTRACTS_GRID, intnx('month', start_date, exposure) as calendar_month
WHERE EXPOSURE <= (TERM+6);
QUIT;

 

Error:

178 EXPOSURE_CONTRACTS_GRID as select * from data2 cross join exposure_grid order by contract_vin, exposure; quit; PROC SQL
178 ! ; CREATE TABLE CONTRACTS_VIN AS SELECT * FROM EXPOSURE_CONTRACTS_GRID, intnx('month', start_date, exposure) as
_
79
178 ! calendar_month WHERE
ERROR 79-322: Expecting a ).

NOTE: Line generated by the invoked macro "DATA".
178 EXPOSURE_CONTRACTS_GRID as select * from data2 cross join exposure_grid order by contract_vin, exposure; quit; PROC SQL
178 ! ; CREATE TABLE CONTRACTS_VIN AS SELECT * FROM EXPOSURE_CONTRACTS_GRID, intnx('month', start_date, exposure) as
_
79
178 ! calendar_month WHERE
ERROR 79-322: Expecting a (.

NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

2 REPLIES 2
FreelanceReinh
Jade | Level 19

As a first step I would correct the select statement:

 

SELECT *, intnx('month', start_date, exposure) as calendar_month FROM EXPOSURE_CONTRACTS_GRID

PGStats
Opal | Level 21

Also, if you want the new date to represent the same day of the month as start_date, and not the first day, as you would get by default, you should use option SAME:

 

intnx('month', start_date, exposure, "SAME") as calendar_month

PG

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1190 views
  • 0 likes
  • 3 in conversation