I need to zip big csv and then to attach to email in sas. any info please?
*if you use windows you may want to use the following options;
*options noxwait xsync;
x 'zip myzipfile.zip /file/to/zip.csv';
filename eml email to="somone@work" attach=("myzipfile.zip" ct="application/zip") subject="Attached File";
data _null_;
file eml;
put "Hi," / / "You zip file is attached" / "Thanks," / "Me";
run;
*if you use windows you may want to use the following options;
*options noxwait xsync;
x 'zip myzipfile.zip /file/to/zip.csv';
filename eml email to="somone@work" attach=("myzipfile.zip" ct="application/zip") subject="Attached File";
data _null_;
file eml;
put "Hi," / / "You zip file is attached" / "Thanks," / "Me";
run;
using EG in winds
What EG connecting to is what matters with the code I posted.
Actually, it does matter. For Enterprise Guide use, the "x" command is disabled, by default. If SASHARP can get the local admin to allow the x command, then FriedEgg's code will work.
You could than also put the x-command (alone) in a code node and then use the EGuide e-mail task to send it out.
Doc Muhlbaier
Duke
Doc Muhlbaier
??put the x-command (alone) in a code node and then use the EGuide e-mail task to send it out??
can you elaborate more?
you can select program --> new program to create a task that is code that you create. That is where you could put the x-command.
However, if you just want to zip the file for e-mail purposes, the directions that FriedEgg provided are perfect.
Doc Muhlbaier
Duke
Thanks Doc@Duke, I often forget about this default.
sassharp, you can check for this using:
proc options option=xcmd; run;
In your log you should see something to the effect of:
XCMD The X Command is valid in this SAS session
This means you can run my example code.
When Doc@Duke says use the EGuide email task to send it out he means to do the following:
Lets say you have your SAS dataset.
You choose to use the EGuide task to export this dataset to CSV. In this step save the results to your local computer as yourfile.csv
In EGuide in the process flow you now have that CSV file available. Right-click on it and you will see a option like Send To -> E-mail Recipient as a Step in Project...
Select the option and the EGuide task window opens, there is a option here to 'Compress all files' You will want to check this option and probably the additoonal option to rename the compressed file to something.
Now you can email your zipped file, code free.
need to automate the process. already used EGuide email Right-click method.
thanks
if you "e-mail recipient as a step in the project" (emphasis added), that will allow you to send the e-mail by scheduling the project, so it provides the automation piece.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.