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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1625 views
  • 0 likes
  • 3 in conversation