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 :).

 

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!

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