BookmarkSubscribeRSS Feed
tparvaiz
Obsidian | Level 7

Hi,

I need to create a table that will update with the dates for the next 15 days, as an example...

DAY        DATE

D_1         30Jun2012:00:00:00

D_2         01Jul2012:00:00:00

D_3         02Jul2012:00:00:00

D_4         03Jul2012:00:00:00

...

Here is the macro that creates a date, but I need to know how to put it in a table

%let today = %sysfunc(today());

%let D_1 = %sysfunc(dhms(%sysfunc(intnx(day,&today,1)),7,0,0),DATETIME20.);

%let D_2 = %sysfunc(dhms(%sysfunc(intnx(day,&today,2)),7,0,0),DATETIME20.);

%let D_3 = %sysfunc(dhms(%sysfunc(intnx(day,&today,3)),7,0,0),DATETIME20.);

%let D_4 = %sysfunc(dhms(%sysfunc(intnx(day,&today,4)),7,0,0),DATETIME20.);

Thanks in advance

1 REPLY 1
Patrick
Opal | Level 21

Why don't you just use a data step like below?

data mydates;

  format date date9. datetime07 datetime21.;

  do date=today() to today()+14;

    datetime07=dhms(date,7,0,0);

    output;

  end;

run;

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
  • 1 reply
  • 396 views
  • 1 like
  • 2 in conversation