BookmarkSubscribeRSS Feed
stevening
Calcite | Level 5

I am trying to center align all images and tables that are in the Image and Table column of a sas table. I am also trying to create a pdf of ods html text= statements. Help would be much appreciated. 

%macro ITreport;
Filename sasp '/home/u59461893/sasuser.v94/sasp.sas';

Data _null_;
Length Line $ 20000;
Set fnb.sample_data;
File sasp;
Line = "ODS HTML TEXT='"||Strip(Image)||"';";
Put Line;
Line = "ODS HTML TEXT='"||Strip(table)||"';";
Put Line;
Line = "ODS HTML TEXT='"||Strip(text)||"';";
Put Line;
Run;
%Include sasp;
%mend ITreport;

ITreport;

 

6 REPLIES 6
ballardw
Super User

I don't see anything that creates ODS output of any type so am a bit confused.

What procedure are you expecting to use? The file you created is plain text and Put will basically left justify when writing to text files with the sytax you use.

 

If you create a variable in a data set and use Proc Print you can specify that the justification for printing a variable is centered. Example:

proc print data=sashelp.class noobs;
   var name /style=[just=c];
run;

You would place the proc print between and ODS PDF <all the options you want> and ODS PDF CLOSE.

 

Or maybe you intended FILE PRINT ODS but you still need to provide some ODS information.

Something like this:

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/odsug/n1ci2fdvszj1j0n1cwax0v19041i.htm

 

stevening
Calcite | Level 5

Hi @ballardw,

 

Thanks for responding. 

 

I have attached an excel file of the data. As you can see, there are three columns called image, text, and table that contain html code of images, text, and tables. I need to extract all the non-missing values from these columns and output it as a pdf. 

 

So I am trying to figure out how to center align <img>...</img> and <table>...</table> and how to output all this html code as a pdf (not as the html code but as html output).

 

I'd appreciate some assistance if you know how to do this.

Cynthia_sas
SAS Super FREQ

Hi:

  To alter the alignment of what you write with ODS TEXT= you typically need a style template change. However, I'm not entirely clear on why you are writing ODS HTML statements to a .SAS file if what you want, ultimately is a PDF file. There are other ways to put images and additional text into a PDF file directly using ODS, as shown in the example below.

 

Cynthia

Cynthia_sas_0-1655307789811.png

 

stevening
Calcite | Level 5

Hi @Cynthia_sas

 

Thanks for your reply, but I don't think your code will work for what I am trying to do.

 

I have attached an excel file of the data. As you can see, there are three columns called image, text, and table that contain html code of images, text, and tables. I need to extract all the non-missing values from these columns and output it as a pdf. 

 

So I am trying to figure out how to center align <img>...</img> and <table>...</table> and how to output all this html code as a pdf (not as the html code but as html output).

 

I'd appreciate some assistance if you know how to do this.

 

 

ballardw
Super User

@stevening wrote:

Hi @Cynthia_sas

 

Thanks for your reply, but I don't think your code will work for what I am trying to do.

 

I have attached an excel file of the data. As you can see, there are three columns called image, text, and table that contain html code of images, text, and tables. I need to extract all the non-missing values from these columns and output it as a pdf. 

 

So I am trying to figure out how to center align <img>...</img> and <table>...</table> and how to output all this html code as a pdf (not as the html code but as html output).

 

 

 


I am afraid that you have just added confusion. Alignment of statements doesn't make much sense in terms of "html output in a pdf file", which is how I read that.That means alignment or not that you execute the html for viewing in a browser and save the result as PDF???

 

Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the <> icon or attached as text to show exactly what you have and that we can test code against.

stevening
Calcite | Level 5

Hi,

 

Thank you for the link on how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the <> icon or attached as text. This was my first post SAS Community so still learning the process. 

 

The following code is a solution my colleague found for those interested:

 

Filename sasp Temp;
Ods html TEXT='^{newline 2}';
Data _null_;
Length Line $ 20000;
Set work.sample_data;
File sasp;
Line = "ODS HTML TEXT='<div style="||'"color: #3498DB; font-family: Arial; font-size: 17pt;margin-left: 100px;">'||Strip(Image)||"</div>';";
Put Line;
Line = "ODS HTML TEXT='<div style="||'"color: #3498DB; font-family: Arial; font-size: 17pt;margin-left: 200px;">'||Strip(table)||"</div>';";
Put Line;
Line = "ODS HTML TEXT='"||Strip(text)||"';";
Put Line;
Run;
%Include sasp;

Then go to print and save the html file as a pdf. Below is a photo of what the SAS table looks like.

 

data.PNG

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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