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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

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
  • 9 replies
  • 1121 views
  • 6 likes
  • 3 in conversation