Hello everyone,
I am facing problem with entering dates manually. Isn't there any loop kind of procedure so that dates get entered automatically.
for eg: I am having a dataset of 21 observations, i want to enter different date infront of each of them. Will i have to enter them manually using cards statement or there is an automated procedure?
Consider that you have the dataset with name have and you need to create a variable date in want. so you could follow as below
the date will create dates from 01jul2017 to 21jul2017 depending on the number of rows
data want;
do until(date ne .);
set have;
date=intnx('day','01jul2017'd,_n_);
end;
format date date9.;
run;
What dates do you want? What do you mean by "entered"? Where do you want it "entered"? How can a date be in front of an observation?
Please provide a litte more detail. For example you could provide a data step to create a copy of your 21 observations and explain what dates you need added.
I want dates from 1st july 2017 to 21st july 2017 infront of every observations. How to do it?
Please anyone reply fast. Refer the above attachment for dataset.
Consider that you have the dataset with name have and you need to create a variable date in want. so you could follow as below
the date will create dates from 01jul2017 to 21jul2017 depending on the number of rows
data want;
do until(date ne .);
set have;
date=intnx('day','01jul2017'd,_n_);
end;
format date date9.;
run;
Hi, curious ... why use a loop in this example ...
data want;
do until(date ne .);
set have;
date=intnx('day','01jul2017'd,_n_);
end;
format date date9.;
run;
Why not just ...
data want;
set have;
date=intnx('day','01jul2017'd,_n_);
format date date9.;
run;
You showed us what you have. What do you need as output - that's unclear.
@atulsingh wrote:
Hello everyone,
I am facing problem with entering dates manually. Isn't there any loop kind of procedure so that dates get entered automatically.
for eg: I am having a dataset of 21 observations, i want to enter different date infront of each of them. Will i have to enter them manually using cards statement or there is an automated procedure?
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!
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.
Ready to level-up your skills? Choose your own adventure.