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!
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.
Easily fixed, with a cup of coffee.
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 :).
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.
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.