BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
maleman
Fluorite | Level 6

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.

1 ACCEPTED SOLUTION
6 REPLIES 6
ChrisNZ
Tourmaline | Level 20

Is it a different image you need to encode each time?

maleman
Fluorite | Level 6

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!

maleman
Fluorite | Level 6

Thank you.  I was able to utilize the x command and write it to a file to accomplish what I needed. 

Kurt_Bremser
Super User

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.

Sharkman
Calcite | Level 5

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

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1919 views
  • 4 likes
  • 4 in conversation