BookmarkSubscribeRSS Feed
anirudhs
Obsidian | Level 7

i am searching for code where it should flag current date & time as 1 and previous all records as 0

e.g. st_date= 13/11/2017 15:30:33 =1

where st_date=13/11/2017 14:30:33 =0;

As i am appending the data to new data set so if it runs multiple times the flag should tag the latest run as 1 rest as 0 

 

Thanks

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

Are you working with a datetime variable or a date and a time variable separately? 🙂

 

Post some example data, that makes it a lot easier to give a usable answer ..

RW9
Diamond | Level 26 RW9
Diamond | Level 26

So if your appending data, and presumably this will continue into the future, what happens to new data nest time?  Or does this process affect all the data new and old?  The logic is simple either way but which you choose depends on your situation:

data want;
  set old new;
  check=ifn(your_date < today(),0,1);
run; 

Or:

data new;
  set new;
  check=ifn(your_date < today(),0,1);
run;
data want;
  set old new;
run;

Assumes real datetime.

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
  • 2 replies
  • 640 views
  • 0 likes
  • 3 in conversation