I am trying to take an image that's stored in my directory, e.g. '~/' and convert the image into a base64 string using SAS Viya 3.5. I can convert text strings to base64, but am having issues with actual images.
Since most images are larger than what a SAS variable can hold, you're better off using a suitable external utility, most likely base64.
Is it a different image you need to encode each time?
There will be different images to encode. I found out from the solution post that I can utilize the x commands in SAS along with macros to complete what is needed. Thank you!
Since most images are larger than what a SAS variable can hold, you're better off using a suitable external utility, most likely base64.
Thank you. I was able to utilize the x command and write it to a file to accomplish what I needed.
If you want to reliably automate external commands from SAS, I recommend to not use the X statement, as it gives you no real information about success or nonsuccess (apart from setting &SYSRC).
Instead, use a pipe:
filename oscmd pipe "<your command here> 2>&1";
data _null_;
infile oscmd;
input;
put _infile_;
run;
All output created by the external command(s) will be written to the SAS log. Since the 2>&1 construct reroutes stderr to stdout, all error messages are also caught and preserved.
Hi!!! I try the code in the next page that works fine: https://support.selerity.com.au/hc/en-us/articles/223345708-Tip-SAS-and-Base64
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: