DATA Step, Macro, Functions and more

do while

Reply
N/A
Posts: 0

do while

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
Super Contributor
Super Contributor
Posts: 3,174

Re: do while

Posted in reply to deleted_user
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
N/A
Posts: 0

Re: do while

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
Super Contributor
Posts: 359

Re: do while

Posted in reply to deleted_user
N/A
Posts: 0

Re: do while

this coding does not work. It shows invalid argument to INTNX.
Super Contributor
Super Contributor
Posts: 3,174

Re: do while

Posted in reply to deleted_user
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.
Super Contributor
Super Contributor
Posts: 3,174

Re: do while

Of course, you should do some desk-checking to verify the SAS NOTE/WARNING/ERROR you are getting first.

Scott
Super Contributor
Posts: 359

Re: do while

Posted in reply to deleted_user
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.
Ask a Question
Discussion stats
  • 7 replies
  • 159 views
  • 0 likes
  • 3 in conversation