BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have a data like
patientid date dose
101 1/03/09 10mg

I want a output like this
patientid date dose
101 1/03/09 10mg
101 2/03/09 10mg
101 3/03/09 10mg
101 4/03/09 10mg
101 5/03/09 10mg
101 6/03/09 10mg

please tell me how to code this program
7 REPLIES 7
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
You can use the INTNX function to increment a value as you have shown using parameter arguments telling SAS how to increment. Though it's unclear what drives the number of output observations you want to generate, I would suggest a DO / END programming paragraph such as:

DATA ;
FORMAT MY_START_DATE MY_DERIVED_DATE MMDDYYS8. ;
MY_START_DATE = TODAY();
DO I=1 TO 6;
MY_DERIVED_DATE = INTNX('MONTH',MY_START_DATE,I);
OUTPUT;
PUTLOG _ALL_;
END;
STOP;
RUN;

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument on this topic:

sas dates intnx site:sas.com Message was edited by: sbb
deleted_user
Not applicable
Dear sbb,

Thanks a lot for your kind information.But this coding does not work shows error that an invalid argument to INTNX .I could not able to find the site of INTNX function .Let me know the site. I shall grateful for early reply.

Thanks,
Regards,
Leena Message was edited by: Leena
deleted_user
Not applicable
this coding does not work. It shows invalid argument to INTNX.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Until you share "your version" of the code, we cannot comment on any type of error you might be getting. I typically test sample code before posting a reply. Suggest you reply with the SAS log output showing your SAS execution -- all of the code, not just a subset.

Scott Barry
SBBWorks, Inc.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Of course, you should do some desk-checking to verify the SAS NOTE/WARNING/ERROR you are getting first.

Scott
Flip
Fluorite | Level 6
Leena;

That would indicate you are using the date text as a value, not a SAS date. There are several methods to convert text to SAS dates.
The SAS date is a numeric value.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 7 replies
  • 1008 views
  • 0 likes
  • 3 in conversation