Dear All,
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,
Scan
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.
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:
https://en.wikipedia.org/wiki/Portable_Network_Graphics
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 @Kurt_Bremser 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.
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?
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.
As @Kurt_Bremser and @RW9 have said, it's probably better to examine what you need for these images and try to build the graphs natively in SAS based on your data, rather than post-process the image.
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.
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.
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.
Many thanks,
Scan
Let's repeat one more time. If you would like help, please post
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.
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.
Do you have the IML interface to R? Can you call Python?
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.
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 16. Read more here about why you should contribute and what is in it for you!
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.