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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 534 views
  • 0 likes
  • 2 in conversation