Programming the statistical procedures from SAS

How to increase date

Reply
N/A
Posts: 0

How to increase date

I have a dataset which contains 3 variables that are patient id date and doses ,I have to increase the date

patient id date doses
101 1jan2009 10mg

I have to create a dataset like
patient id date dose
101 1jan2009 10mg
101 2jan2009 10mg
101 3jan2009 10mg
101 4jan2009 10mg
101 5jan2009 10mg


please tell me how I increase the date.

Thanks,
Regards,
Bina
Respected Advisor
Posts: 4,016

Re: How to increase date

data have;
infile datalines;
input patient_id date anydtdte. doses $;
format date date9.;
datalines;
101 1jan2009 10mg
;

data want(drop=i);
set have;
do i=1 to 5;
output;
date=date+1;
end;
run;

proc print data=want;
run;
Super Contributor
Super Contributor
Posts: 3,174

Re: How to increase date

Most important for the OP to understand the SAS DATE variable (numeric) content - suggested link provided below from SAS DOC.

Also, it is possible to work with a DO / END code paragraph incrementing a variable from a starting date (constant) to an ending date, as shown below:

DO I=INTNX('MONTH,TODAY(),0) TO INTNX('MONTH',TODAY(),+1);
* YOUR CODE GOES HERE. ;
END;

Both the INTNX and INTCK functions are quite powerful in a DATA step process to increment and also generate ranges of date-variable values.

Scott Barry
SBBWorks, Inc.

SAS Language Reference: Concepts, About SAS Date, Time, and Datetime Values
http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a002200738.htm
N/A
Posts: 0

Re: How to increase date

Dear sbb,
Thanks a lot for your kind information.
Thanks,
Regards,
Leena
N/A
Posts: 0

Re: How to increase date

Dear Patrick,
Thanks a lot for your kind information this code work perfectly.

Thanks,
Regards,
Leena
Ask a Question
Discussion stats
  • 4 replies
  • 99 views
  • 0 likes
  • 3 in conversation