01-23-2017 07:01 AM
is it possible to split a single png image into two different png files with SAS?
Let's say dividing a file IMAGE.png into the upper 80% portion of the image and the 20% on the bottom, saving them as TOP.png and BOTTOM.png, keeping the same resolution?
Many thanks, any hint appreciated,
01-23-2017 07:04 AM
SAS is really not an image manipulation utility. I'd suggest dedicated software like IrfanView, Potoshop or gimp for this.
gimp should have something that can be used from the commandline.
01-23-2017 07:38 AM
Well, yes, it is possible. Depends if you have 6 months or so to write a parser for the filetype. File format is given here:
Nothing stopping you form reading in the binary data, manipulating as you want, then writing out.
Is this a good idea, no. Why are you attempting to use a picture? Go back to the srouce data, and regenerate the output with the part you want. Alternatively use a paint app as @KurtBremser has said, however I personally see that as not being a good idea either, the whole picture would be there for a reason, chopping out a certain bit of it just removes most of the consolidating reference data. Take for example a graph, the axis is there so the points have reference, you could chop out a bit, but does it still convey anything.
01-23-2017 08:14 AM - edited 01-23-2017 08:16 AM
Thank you all,
I need to do it in SAS and no, unfortunately I don't have 6 months.
Any workaround? As an example I think that probably it is possible trying to fit it in a smaller box, basically cutting the bottom side of the image. But what about the upper side?
01-23-2017 08:20 AM - edited 01-23-2017 08:21 AM
Let's repeat: SAS does NOT have built-in image manipulation tools. Period. To manipulate an existing image, you would have to write that byte-by-byte yourself. Use a proper tool (easily available for all platforms, as mentioned) to do this.
01-23-2017 08:32 AM
SGPLOT supports a "broken axis" that might help you to segment your report. Otherwise, you might be able to build what you need in GTL. You can start with the ODS Graphics Designer to build a layout with your data, which will generate the code that you can then process with PROC SGRENDER.
01-23-2017 08:33 AM
Please post your image so we can see what is in it. Also post the version of SAS that you are using.
We can then suggest ways to produce output that might meet your business objectives.
01-23-2017 11:38 AM - edited 01-23-2017 11:44 AM
Thanks for the interest.
Basically I have a KM graph with patients at risk at the bottom.
This is produced with a layout lattice with united datarange in order to align the two elements.
I want to produce 2 different png mantaining the alignment.
I solved for the moment creating 2 different png files with the same templating simply changing the vertical dimension of the graph and assigning the row dimension to (0.99 0.01) to the km graph and (0.01 0.99) to the second element with pt at risk.
I still have the labels of the second element creating a black box on the left bottom of the km graph, solved it whitening the text.
This is very dirty but works.
If you have better hints on how to proceed I will be glad to accept them.
Is there a way to delete the space between the border of the graph (max y-axis) and the border of the image (on the top)?
Because I'm actually having a lot of space between the first and second element.
I tried to define a style with
proc template; define style NEWSTYLE; parent = styles.listing ; replace Body from Document / bottommargin = 0 cm topmargin = 0 cm rightmargin = 0 cm leftmargin = 0 cm ; replace Body from Output / bottommargin = 0 cm topmargin = 0 cm rightmargin = 0 cm leftmargin = 0 cm ; end; run;
but it does not work.
I'm running on 9.4.
01-23-2017 11:47 AM
Let's repeat one more time. If you would like help, please post
01-23-2017 11:50 AM
Thank you Rick,
probably tomorrow I'll be free to adapt the code to a sashelp dataset.
As you know I can't post code/datasets before making it completely generalised.
Many thanks for the help so far, not only today.
I'll return here with the requested things.
01-23-2017 01:29 PM
Instructions at https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... turn a dataset into data step code.
It shouldn't be hard to obfuscate a few variables to demonstrate what you are doing.
01-25-2017 09:14 PM
If you create your plots with SAS/GRAPH (proc gplot rather than proc sgplot), you can use proc greplay to put them back together as one plot, positioning them as you like, including overlapping to hide parts of some graphs.
As far as I know, the SG procedures cannot output to catalog, and there is no proc sgreplay.