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,
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();
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?
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();
I want create a new variable as
the first run
recorded_date = today();
second run as
recorded_date=today() + previous date();
thanks,
kesete
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.
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.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: