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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 725 views
  • 0 likes
  • 3 in conversation