Including a DateTimeStamp in a dataset name

Accepted Solution Solved
Reply
Contributor
Posts: 40
Accepted Solution

Including a DateTimeStamp in a dataset name

Hi

I am trying to create a dataset with a system date and time as part of the name, but am not winning.  Conceptually, I am trying to do something like this :

proc freq data=lib.set1 noprint;

  tables book*lastAssignedQueue / out=lib.Freq1_&sysDate._&sysTime (drop=percent);

run;

It is not working because of the ":" in systime.  Any suggestions please ?


Accepted Solutions
Solution
‎07-31-2014 05:42 AM
Super User
Super User
Posts: 7,392

Re: Including a DateTimeStamp in a dataset name

Hi,

Try:

data want_&sysdate._%sysfunc(compress(&systime.,": "));

  set sashelp.cars;

run;

View solution in original post


All Replies
Solution
‎07-31-2014 05:42 AM
Super User
Super User
Posts: 7,392

Re: Including a DateTimeStamp in a dataset name

Hi,

Try:

data want_&sysdate._%sysfunc(compress(&systime.,": "));

  set sashelp.cars;

run;

Contributor
Posts: 40

Re: Including a DateTimeStamp in a dataset name

Thanks RW - perfect !

Contributor
Posts: 40

Re: Including a DateTimeStamp in a dataset name

One more thing.  The sysdate and systime are related to the date and time I opened the SAS session.  Is there any way I can get the real time when the job is submitted ? i.e. the SAS session was opened at 08h00 and I submitted the job at 12h06, but the time I ge from systime is 08h00

Super User
Super User
Posts: 7,392

Re: Including a DateTimeStamp in a dataset name

As far as I know there is no macro variable for time SAS started.  You could however put some code in your autoexec.sas file:

data _null_;

     call symput('SAS_INIT_TIME',&sysdate._%sysfunc(compress(&systime.,": ")));

run;

Then use that macro variable in you programs.

Super User
Posts: 9,671

Re: Including a DateTimeStamp in a dataset name

Use real function .

data want_&sysdate._%sysfunc(compress(%sysfunc(time(),hhmm8.),": "));

  set sashelp.cars;

run;

Xia Keshan

Contributor
Posts: 40

Re: Including a DateTimeStamp in a dataset name

Thanks RW and KSharp - much qppreciated

☑ This topic is SOLVED.

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

Discussion stats
  • 6 replies
  • 303 views
  • 0 likes
  • 3 in conversation