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 :).
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.