Desktop productivity for business analysts and programmers

ods html path error

Reply
New Contributor
Posts: 2

ods html path error

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

Super Contributor
Posts: 308

Re: ods html path error

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 ?

New Contributor
Posts: 2

Re: ods html path error

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. 

Super User
Posts: 7,431

Re: ods html path error

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;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 3 replies
  • 291 views
  • 0 likes
  • 3 in conversation