BookmarkSubscribeRSS Feed
kirankp
Fluorite | Level 6

Hello Everyone,

 

Can some one help me as how to add the password for the zip file to open:

 

Following is my programming, please suggest - 

 

%LET DIRECTORY=%SCAN(&sysparm,1,%STR( ));

FILENAME INFILES "&directory";
FILENAME EXELOG "&directory\LOGLIS\&sysdate9..LOG";

LIBNAME OUTLIB V8 "&directory";


data _null_;
call symput('date',(put(date(),yymmddn8.)));
run;

/* ods begin */
ods package(ProdOutput) open nopf;
ods package(ProdOutput)
add file= "&directory\DONKEY_XX_Conc_HHHH_%sysfunc(today(),YYMMDDN8.).csv";

ods package(ProdOutput)
publish archive
properties
(archive_name= "DONKEY_XX_%trim(&date.).zip"
archive_path="&directory");
ods package(ProdOutput) close;
/* ods end */

FILENAME OUTLIS "&directory\LOGLIS\check.LIS";

/* delete original files after creating the zip file */
FILENAME fileref1 "&directory\DONKEY_XX_Conc_HHHH_%sysfunc(today(),YYMMDDN8.).csv";
%put %sysfunc(fdelete(fileref1));
FILENAME fileref1 "&directory\DONKEY_XX_Conc_HHHH_%sysfunc(today(),YYMMDDN8.).csv";
%put %sysfunc(fdelete(fileref1));

 

PROC PRINTTO PRINT=OUTLIS NEW;
RUN;

8 REPLIES 8
japelin
Rhodochrosite | Level 12

You may find this post helpful.

https://communities.sas.com/t5/ODS-and-Base-Reporting/Using-ODS-to-password-protect-file/td-p/509182

 

By the way, I have done the process of adding passwords using 7zip in a Windows environment, as shown in the url posted by reeza.

kirankp
Fluorite | Level 6
It is of no use, can you suggest how to incorporate it in the current
programming
japelin
Rhodochrosite | Level 12

Please provide your environment first.

 

Why is it of no use?

Just create the zip file and then run the command.
If you want to include it in your program, it should be before "PROC PRINTTO PRINT=OUTLIS NEW;".

kirankp
Fluorite | Level 6
Thank You for kind response.

Following is the code I have used to create the zip file, after this how to
add the code for zip password. Can you please suggest, I will be grateful.

Code:

data _null_;
call symput('date',(put(date(),yymmddn8.)));
run;

/* ods begin */
ods package(ProdOutput) open nopf;
ods package(ProdOutput)
add file= "&directory\DONKEY_XX_Conc_HHHH_%sysfunc(today(),YYMMDDN8.).csv";

ods package(ProdOutput)
publish archive
properties
(archive_name= "DONKEY_XX_%trim(&date.).zip"
archive_path="&directory");
ods package(ProdOutput) close;

/* ods end */


《Please provide the programming code as how to give password for above zip
file generated》


Regards,

Kiran

japelin
Rhodochrosite | Level 12

On Windows, it can be rewritten as follows.
7zip will create the zip file, so no ods statement is needed.

 

options noxwait xsync;
data _null_;
  call symput('date',(put(date(),yymmddn8.)));
run;
x " ""C:\Program Files\7-Zip\7z"" a 
    ""&directory\DONKEY_XX_%trim(&date.).zip"" 
    ""&directory\DONKEY_XX_Conc_HHHH_%trim(&date.).csv""
    -pPASSWORD";

You can modify the 7zip path if necessary.

 

kirankp
Fluorite | Level 6

I am getting this error and not able to append the password.

 

x " ""E:\Program Files\7-Zip\7z"" a
""&directory\DONKEY_XX_%trim(&date.).zip""
WARNING: The quoted string currently being processed has become more than 262 characters long. You might have unbalanced quotation marks.

 ""&directory\DONKEY_XX_Conc_Result_%trim(&date.).csv""
 -pPASSWORD"
 ! ;

 

how to solve this.

japelin
Rhodochrosite | Level 12

How many characters is the folder path assigned to &directory?
Also, what happens if I don't use the macro variable and specify the actual folder?

kirankp
Fluorite | Level 6
I am using SAS 9.3

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!

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
  • 8 replies
  • 1727 views
  • 0 likes
  • 2 in conversation