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-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
  • 6 replies
  • 941 views
  • 0 likes
  • 5 in conversation