BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sassharp
Calcite | Level 5

I need to zip big csv and then to attach to email in sas. any info please?

1 ACCEPTED SOLUTION

Accepted Solutions
FriedEgg
SAS Employee

*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;

View solution in original post

9 REPLIES 9
FriedEgg
SAS Employee

*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;

sassharp
Calcite | Level 5

using EG in winds

FriedEgg
SAS Employee

What EG connecting to is what matters with the code I posted.

Doc_Duke
Rhodochrosite | Level 12

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

sassharp
Calcite | Level 5

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?

Doc_Duke
Rhodochrosite | Level 12

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

FriedEgg
SAS Employee

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.

sassharp
Calcite | Level 5

need to automate the process. already used EGuide email Right-click method.

thanks

Doc_Duke
Rhodochrosite | Level 12

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 9 replies
  • 1524 views
  • 6 likes
  • 3 in conversation