BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
4 REPLIES 4
Patrick
Opal | Level 21
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;
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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
deleted_user
Not applicable
Dear sbb,
Thanks a lot for your kind information.
Thanks,
Regards,
Leena
deleted_user
Not applicable
Dear Patrick,
Thanks a lot for your kind information this code work perfectly.

Thanks,
Regards,
Leena

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!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1160 views
  • 0 likes
  • 3 in conversation