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

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2754 views
  • 4 likes
  • 3 in conversation