BookmarkSubscribeRSS Feed
vikramhm
Calcite | Level 5

Hi,

 

My requirement is to create html reports under the current date folder.

 

In my below code, after creating the current date folder, I am facing issues when I assign ods html path=outdir. How to reference the path through the variable to create the html reports? Please help.

 

data _null_;
date=today();
put 'SAS date=' date yymmddn8.;
dir=Compress(put(date, yymmddn8.),' ');
put dir=;
dir1= dcreate(dir,'C:\SAS\');  /* this will create folder for the current date*/

outdir=compress('\\Gcwcnappv01021\sas_dev\TestFolder\'||dir,' ');
run;

 

/* Below lines to create html file*/

ods html path=outdir (url=none) 
body='SASReport.html'
style=harvest;

proc report ;

title1 'SAS Report';
title2 "%sysfunc(date(),worddate18.)";
run;
ods _all_ close;

 

 

Regards

Vikram

3 REPLIES 3
Loko
Barite | Level 11

Hello,

 

You are creating a data base variable (outdir) which value you expect to be available outside the data step.

The only variables that cand translate beyond the data step are macro variables.

 

Anyway, since you clearly state the path why don't you state it in the ods html statement ?

vikramhm
Calcite | Level 5

Hi,

 

As i am creating the current date folder which is not static, i cannot directly state in ods html statement. So i am deriving the path( for current date) and then specifying it in ods html statement though the variable. 

Kurt_Bremser
Super User

Since you already create the filename in your data step, just store it into a macro variable:

data _null_;
date=today();
put 'SAS date=' date yymmddn8.;
dir=Compress(put(date, yymmddn8.),' ');
put dir=;
dir1= dcreate(dir,'C:\SAS\');  /* this will create folder for the current date*/
outdir=compress('\\Gcwcnappv01021\sas_dev\TestFolder\'||dir,' ');
call symput('outdir',trim(outdir));
run;

/* Below lines to create html file*/

ods html path="&outdir" (url=none) 
body='SASReport.html'
style=harvest;

proc report ;

title1 'SAS Report';
title2 "%sysfunc(date(),worddate18.)";
run;
ods _all_ close;

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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