BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
atulsingh
Obsidian | Level 7

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

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;
Thanks,
Jag

View solution in original post

6 REPLIES 6
Tom
Super User Tom
Super User

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.

atulsingh
Obsidian | Level 7

I want dates from 1st july 2017 to 21st july 2017 infront of every observations. How to do it?


sas.png
atulsingh
Obsidian | Level 7

Please anyone reply fast. Refer the above attachment for dataset.

Jagadishkatam
Amethyst | Level 16

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;
Thanks,
Jag
MikeZdeb
Rhodochrosite | Level 12

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;

Reeza
Super User

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?


 

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1235 views
  • 0 likes
  • 5 in conversation