BookmarkSubscribeRSS Feed
bhong
Calcite | Level 5

Hi,

 

For some reason, my INTNX function is not working and is returning a missing value. I just want to move forward one month. Here's some code:

 

DATA test;
	SET membership1;
	IF _N_ in (16) THEN OUTPUT;
	format DT_CHECK mmddyy10.;
	DT_CHECK = intnx("month", EVENT_DT, 1);
RUN;

EVENT_DT is a SAS date (e.g., 01/25/2013)  and is formatted as mmddyy10. My dataset has over 12,000 observations, so I wanted to just read in the 16th observation as a test. Can anyone help me fix my code? Thanks!

4 REPLIES 4
Astounding
PROC Star

The DATA step statements execute in order, from top to bottom.

 

You are outputting before computing DT_CHECK.

 

Move the OUTPUT statement to the bottom of the DATA step.

bhong
Calcite | Level 5
Thank you! What a horrible mistake!
Astounding
PROC Star

Easily fixed, with a cup of coffee.

Haikuo
Onyx | Level 15

Following @Astounding's suggestion, you will get what you need. However, theoretically speaking, you don't just READ-IN the 16th record,  you OUTPUT the 16th record while reading in every single record in your incoming dataset.

 

 To actually only READ-IN the 16th, you need either resort to point= option, or bring in the data only with the 16th record, such as:  

DATA test;
SET membership1(firstobs=16 obs=16);

blah...

 

I know 12,000 probably only takes blink of eye to run, but if you are doing multi-M or B rows of data, this little test will still cost you some time :).

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 2717 views
  • 4 likes
  • 3 in conversation