BookmarkSubscribeRSS Feed
mmea
Quartz | Level 8

Hi I have several proc reports that should be in an Excel file


ODS EXCEL FILE="F:\COVID-19\ \Data\COVID-19  Report(%sysfunc(date(),date9.) %sysfunc(time(),HHMM.)).xlsx" 
	options(sheet_name = 'Tabel 1'
			embedded_titles = 'yes' 
			embedded_footnotes = 'yes' 
            orientation = 'landscape'   
			)  
	author='dsjfsjdk ';

ods noproctitle;
ods noptitle;
title;

I Start it like this - but it gives me this error:

error "A component of directory-name is not a directory" 

I put the right directory, what can the problem be?

 

3 REPLIES 3
Kurt_Bremser
Super User

The colon (created by the HHMM format) is not allowed in Windows file names.

Instead of

%sysfunc(time(),HHMM.)

use

%sysfunc(compress(%sysfunc(time(),hhmm.),:))

And I strongly recommend to NOT use the DATE9 format in filenames, use YYMMDDN8 or YYMMDD10 instead. This sorts nicely.

mmea
Quartz | Level 8

Okay thanks!

How can I do it if I want the time to give me just hour like this "13:00" 

Kurt_Bremser
Super User

Use the INTNX function to align times to full hours:

data _null_;
ftime = intnx('hour',time(),0,'b');
cftime = compress(put(ftime,hhmm.),":");
call symputx("ftime",cftime);
run;

%put &=ftime.;

I used the DATA _NULL_ to keep the code readable (I don't like SYSFUNC avalanches).

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 901 views
  • 0 likes
  • 2 in conversation