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

Dear expert,

 

I have a program which runs every day and I want to recorded the date.

 How do I keep the date without overwritten the previous date?

 

Here is the sample Output.

ID

Recorded date

000

01/12/2017

111

01/13/2017

222

01/13/2017

333

01/13/2017

444

01/13/2017

555

01/13/2017

666

01/14/2017

777

01/14/2017

888

01/14/2017

999

01/14/2017

112

01/15/2017

221

01/15/2017

113

01/15/2017

 

 

thanks,

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Keep the date?  Where?  You can add a new variable each time the program runs, but that doesn't seem practical.  If you have only one variable to hold the date,  you can leave it alone or replace it.  If you only want to replace missing date values, you could code:

 

if recorded_date = . then recorded_date = today();

 

 

View solution in original post

4 REPLIES 4
ballardw
Super User

You need to provide more information. How are you storing/ selecting/setting the date currently? Some code describing your current process would help.

 

The most likely way I can think of destroying existing data is to reuse a data set name. Perhaps you need to APPEND todays data set to the previous data set?

Astounding
PROC Star

Keep the date?  Where?  You can add a new variable each time the program runs, but that doesn't seem practical.  If you have only one variable to hold the date,  you can leave it alone or replace it.  If you only want to replace missing date values, you could code:

 

if recorded_date = . then recorded_date = today();

 

 

tekish
Quartz | Level 8

I want create a new variable as 

the first run

recorded_date = today();

second run as

recorded_date=today() + previous date();

 

thanks,

kesete

Patrick
Opal | Level 21

You've already marked an answer as correct but now reading your consecutive post it looks like you're not there yet.

 

Assuming previous date() stands for the max. date already loaded in a previous run, a formula like today() + previous date() would return a date in the year 4034 which I assume is not what you want.

 

It's not clear to me what you're actually trying to achieve, but let's assume you have a master dataset where you collect daily increments.

If this is just about appending these daily increments then first add a date of today() to your incremental data - recorded_date=today(); - and then use Proc Append to append the new incremental data to your existing master data set.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 843 views
  • 1 like
  • 4 in conversation