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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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