BookmarkSubscribeRSS Feed
SachinRuk
Calcite | Level 5
Hi all,

I have a table for example:

variable 1 2 3 4 5 6
x 323 34 45 ........... 32
y 23 ....... 25
z 58........................................ 65

how do i print this out as is to a html?
also I have already managed to print out a graph of the above table. will the print statement overwrite this graph?

thanks,
sachin
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
Hi:
What do you mean by the PRINT statement??? PROC PRINT??? PROC REPORT???

Consider the example at the bottom of this post. The PROC PRINT output does not "rewrite" the graph. This is because if you look at the underlying HTML, you will see that the SAS/GRAPH procedure causes ODS HTML to insert an <IMG> tag into the HTML output file. The image is not embedded into the HTML file -- only the <IMG> tag appears in the HTML file.

cynthia
[pre]
ods html path='c:\temp' (url=none)
gpath='c:\temp' (url=none)
file='print_graph.html'
style=sasweb;

proc print data=sashelp.class;
title 'SASHELP.CLASS';
run;

proc gchart data=sashelp.class;
title 'GCHART';
vbar age /discrete sumvar=height type=mean;
run;
quit;

ods html close;
[/pre]
SachinRuk
Calcite | Level 5
Hi Cynthia,

Thanks, that helped alot. but with the same above. suppose I wanted to format the values (say height) and for some reason it was a percentage. How could i set it so that the values displays a percentage sign?

Also aside from this, is there any reason why I should use proc report over proc print?

Thank You,
Sachin
Cynthia_sas
SAS Super FREQ
Hi:
If you wanted to format HEIGHT, you would use a FORMAT statement in a procedure that used FORMAT statements, such as:
[pre]
format height fmt-name.;
[/pre]

For percentages, you have to know ahead of time whether the number has been multiplied by 100 or not. For example -- let's say you have a variable called PCTVAL with a number like .3456 -- the SAS pre-defined PERCENT format would do an automatic multiply by 100 -- so the number could display as 34% or 34.56% depending on your format: PERCENT8.0 or PERCENT8.2 (this means you have to know what your number looks like). Your FORMAT statement would be:
[pre]format PCTVAL percent8.2;[/pre]


If your number had already been multiplied by 100 and was stored as 34.56, then you would NOT want to use the pre-defined PERCENT format. In order to just attach a percent sign without doing the multiply by 100, you would need to define your own PICTURE format, as described here (and in previous forum postings):
http://support.sas.com/kb/36/495.html
(the note talks about using a PICTURE format with PROC TABULATE because that is a procedure that calculates percents, but automatically does a multiply by 100)

To use a PICTURE format, such as the one described in the Tech Support note, you would, again, use a FORMAT statement:
[pre]format PCTVAL mypct.;[/pre]

As to whether you should use PROC PRINT or PROC REPORT it really is up to you -- PROC REPORT can produce both detail (one report row for every obs) as well as summary reports (one report row represents the summary of multiple obs); while PROC PRINT can only do detail reports; PROC PRINT will produce a sub-total and a grand-total; PROC REPORT can produce one or the other or both. PROC REPORT allows you to highlight an entire row based on some value; PROC PRINT only allows the highlighting of individual cells. PROC REPORT has the COMPUTE block that lets you adjust processing, create custom text strings at a break and perform conditional highlighting (such as one row with commas and another row with dollar signs). PROC REPORT allows you to put spanning headers in your header area -- PROC PRINT does not.

But if all you need is a simple detail report of your dataset -- PROC PRINT is quick and definitely easy to use. PROC REPORT syntax is a bit more verbose. If you were going to "pre-summarize" your data with PROC MEANS, for example and then do a PROC PRINT, I'd recommend switching to PROC REPORT because it can do the summarizing and the report in the same step. But if all you needed was a simple detail report, and you're just starting out, I'd probably recommend PROC PRINT.

cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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