SAS Programming

DATA Step, Macro, Functions and more
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 2526 views
  • 4 likes
  • 4 in conversation