- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Since most images are larger than what a SAS variable can hold, you're better off using a suitable external utility, most likely base64.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Is it a different image you need to encode each time?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Since most images are larger than what a SAS variable can hold, you're better off using a suitable external utility, most likely base64.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you. I was able to utilize the x command and write it to a file to accomplish what I needed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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