BookmarkSubscribeRSS Feed
HeatherNewton
Quartz | Level 8

 

data testdata;
input cost_mth $9. monyyyy $10.;
datalines;
20NOV2023 NOV2023
1NOV2023 DEC2023
30NOV2023 DEC2023
;
RUN;

proc print data=testdata;run;

* cost_mth=21JAN2009 MONYYYY=DEC2006

proc sql;
create table default_cnt as 
select
intnx('month',cost_mth,0,'e') as default_mth format=date9. 
from testdata;
quit;

proc print data=default_cnt;
run;

DATA result;
set testdata;
test1=PUT(monyyyy,MONYY7.);
test2=PUT(A.default_mth+1, MONYY7.);
run;


proc print data=result;
run;

why doesnt my code works, it says out of proper order for the intnx statement

please helo

2 REPLIES 2
PaigeMiller
Diamond | Level 26

When code doesn't work, please show us the ENTIRE log (not just the error messages)

--
Paige Miller
BrunoMueller
SAS Super FREQ

There are a few changes needed for your program.

 

I would code the first DATA step to actually read the values as dates and not as character value, like so:

data testdata;
input cost_mth : date9. monyyyy : monyy7.;
format cost_mth monyyyy date9.;
datalines;
20NOV2023 NOV2023
1NOV2023 DEC2023
30NOV2023 DEC2023
;

Second you are missing the ";" in you comment statement

 

In your last DATA step you read the data from the first DATA step, this data set is missing the default_mth variable (in the DATA step you just use the name of a variable, so A.default_mth will not work). Your SQL creates a table with one variable. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 2 replies
  • 242 views
  • 0 likes
  • 3 in conversation