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
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 ?
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.
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.