DATA Step, Macro, Functions and more

keep the date each day

Accepted Solution Solved
Reply
Contributor
Posts: 58
Accepted Solution

keep the date each day

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,

 


Accepted Solutions
Solution
‎01-13-2017 07:56 PM
Super User
Posts: 5,518

Re: keep the date each day

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


All Replies
Super User
Posts: 11,343

Re: keep the date each day

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?

Solution
‎01-13-2017 07:56 PM
Super User
Posts: 5,518

Re: keep the date each day

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();

 

 

Contributor
Posts: 58

Re: keep the date each day

Posted in reply to Astounding

I want create a new variable as 

the first run

recorded_date = today();

second run as

recorded_date=today() + previous date();

 

thanks,

kesete

Respected Advisor
Posts: 4,173

Re: keep the date each day

[ Edited ]

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.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 194 views
  • 1 like
  • 4 in conversation