Desktop productivity for business analysts and programmers

create a html file with a variable value

Reply
New Contributor
Posts: 3

create a html file with a variable value

Hello,

I am trying to generate a html file with a variable value. I am trying it with proc print and ods:

%let fecha=20141013;

data disponibilidad;
   fecha=&fecha;
run;

ods html file='C:\example.htm' ;
proc print data=disponibilidad label;
run;
ods html close;

The problem es that the html ganerated has column headers and one column with the obs number. is it possible to dissable them? i just need the value ot the variable.

Thank you

Super Contributor
Posts: 339

Re: create a html file with a variable value

You can suppress the number of observations with "NoObs", but I think you need to switch to proc report to remove the variable name:

Proc Report Data=disponibilidad Nowd;

  Define fecha/display ' ';

Run;

Super User
Super User
Posts: 7,727

Re: create a html file with a variable value

Well, observations is easy to get rid of, just add option nooobs:

proc print data=xyz noobs;

For the second part the column headers.  This is a fundamental part of SAS.  It deals with tables which have headers.  You can try assigning a missing to the label =

data disponibilidad;

   fecha=&fecha;

     label fecha " ";

run;

Might help.  Or put your test into a title/footnote statement.  If you provide example of what you want out we could suggest.

New Contributor
Posts: 3

Re: create a html file with a variable value

Thank you very much,

i tryied with this:

%let fecha=20141013;

data disponibilidad;
  fecha=&fecha;
   label fecha " ";
run;

ods html file='C:\Users\adelaigm\Desktop\A.htm' ;
proc print data=disponibilidad noobs label;
run;
ods html close;

obs column problem solved, but the header "fecha" is still appearing. Any other suggestion?

may be is possible to resize the html in order to hidde the area i dont want to display...

Super User
Super User
Posts: 7,727

Re: create a html file with a variable value

Maybe if you can provide an example of the output.  As user24feb mentioned, try out proc report.  You can hide borders then as well (or color them the same as background.

However if you want text outside the table structure, then you are better off putting it in a title statement.

New Contributor
Posts: 3

Re: create a html file with a variable value

Thank you so much,

I finally did it with a proc report. As long as i dont need any format at all, i export the file as a csv instead of html, but ithe rename the file to .html, so i could get a plane hmtl with the variable value.

title;

ods csv file='C:\Users\adelaigm\Desktop\report2.html' ;

Proc Report Data=disponibilidad Nowd;

  Define fecha/display ' ';

Run;

ods csv close;

Super User
Posts: 11,144

Re: create a html file with a variable value

A data _null_ might work;

Instead of proc print:

data _null_;

     set disponibilidat;

     file print;

     put fecha;

run;

This is very old school, but will generate output with no column headers. For multiple variables you will likely want to look up the options that control column position start locations and formats.

Super User
Posts: 19,194

Re: create a html file with a variable value

Use ODS HTML TEXT =

%let fecha=20141013;

title;

ods noptitle;

ods html file='C:\temp\sample.html';

ods html text="&fecha";

ods html close;

Ask a Question
Discussion stats
  • 7 replies
  • 378 views
  • 6 likes
  • 5 in conversation