10-19-2012 10:12 AM
I have some data files that I would like to password protect for security reasons but still be able to import and manipulate in SAS. Most of the data manipulations are summary of the stats so I'm not as worried about the security of the final data form.
Is this possible and how do I do it? Thanks very much.
10-19-2012 12:51 PM
If your 'data files' are SAS data sets, there are a series of data set options that can be used to provide various levels of password and/or encryption. http://support.sas.com/documentation/cdl/en/ledsoptsref/63326/HTML/default/viewer.htm#n03k13diwk36x1...
10-19-2012 05:02 PM
I apologize because I didn't explain myself well. I realize I can't password protect a .txt file so I guess I meant have in a zipped, password protected folder and extract from there.
Your post will be useful for when I have extracted the text into a SAS data set, but I'm talking about before I've even imported it.
Thanks very much for replying.
10-19-2012 06:40 PM
I think you can.
1. can you use x commands at your site?
2. Are you using Windows SAS or SAS on a Server?
3. What zipped the file, 7Zip or WinZIP?
10-19-2012 07:30 PM
Have you considered placing the unzipped text files in a folder/directory to which you have exclusive read/write access? I have seen this used successfully in several sites. The advantage is that you can read and analyse the data without any password requirement, but other users cannot access the data even if they use your code. Once the data has been read it can be zipped and password protected for archive, for additional security. The same folder can be the library holding record level datasets, if required.
10-22-2012 10:17 AM
If those files are "restorable" with a system command then there should be no problem to import them through a pipped command line.
You just have to adjust your previous file assignment to a proper file pipe command assignment. Now, important thing is, beside providing the necessary password you need to add the flag which redirects processing to screen/console (in order to pipe the result). You'll have to find this flag in the zip command documentation you're using.
On Unix using the zip command, it should look like this (-c is the flag which redirects output to screen):
* flags: -c output to stdout, -q quiet mode, -P specify the password;
filename myfile pipe 'unzip -cq –P mypass FILE.zip' ;
infile myfile; * import file;
Cheers from Portugal.
Daniel Santos @ www.cgd.pt
10-22-2012 03:42 PM
Thank you all for such detailed answers!
As for what I have "on-site", I am an off-site consultant and keep the data on my drive. I have encrypted files, security software etc. but want to take extra steps to ensure that the data is not compromised via hacking or anything so being able to extract from a zipped file makes the most sense.
I'll review all responses in more detail and may have more questions....thanks again to all of you. I love this site!!
01-30-2013 12:33 PM
I'm still working on this and though I posted about SASZIPAM earlier today, I would still like to review your PIPE method.
You provided me with the code using the Unix zip command but can you advise where I can find out about the Windows (7) one? Thanks.
01-30-2013 12:39 PM
To use the x command to unzip files on the PC requires a special (a.k.a. extra cost) add-on for WinZip. However, 7Zip includes that tool in its distribution (and 7zip can process WinZip encrypted files). Of course, this adds the extra layer of protecting the password in your SAS code.
01-30-2013 01:39 PM
Thanks for your reply. Right now each single file is in a winzip folder and I'm going to be combining them into one so I will look at 7Zip.
01-30-2013 04:11 PM
I don't know what the issue is but I can't get this to work either.
This is the error log:
1 filename test Pipe '7za e "F:\files\Test.7z"
2 "myfile.txt" -y -so';
4 data import_test;
5 infile test;
7 input @1 Prov $1.
8 @2 Inst $4.
9 @6 Fyear $4.
10 @10 Period $2.
11 @12 Batch $2.
12 @14 AbsNo $3.
13 @18 Coder $2.
14 @20 ChartNo $10.
15 @30 RegNo $7.
16 @37 SecChartNo $10.
17 @47 MatNBChart $10.
18 @57 HCN $12.
19 @69 Postal $6.
20 @75 Rescode $7.
21 @82 Sex $1.
22 @83 ProvHCN $2.
23 @85 RFP $2.;
NOTE: The infile TEST is:
Unnamed Pipe Access Device,
PROCESS=7za e "F:\files\Test.7z""myfile.txt"
'7za' is not recognized as an internal or external command,
operable program or batch file.
NOTE: 0 records were read from the infile TEST.
NOTE: The data set WORK.IMPORT_TEST has 0 observations and 17 variables.
NOTE: DATA statement used (Total process time):
real time 0.04 seconds
cpu time 0.03 seconds
Is there something wrong with my code and if not, what should I be troubleshooting? Thanks.
01-30-2013 05:54 PM
Just an FYI that the software to use the x command for WinZip is a free download so I tried that. Based on the information, including the syntax to do so, I ran the program below but it isn't extracting from the text file portion. The log doesn't indicate any errors, just that "0 records were read from the infile testing".
Can someone please advise why this isn't working? Any and all assistance greatly appreciated.
filename testing pipe '"C:\Program Files\WinZip\wzunzip.exe" -vb F:\myfolder\Test.zip test.txt';
infile testing truncover LRECL = 5000 firstobs=10;
input @1 Prov $1.
@2 Inst $4.
@6 Fyear $4.
@10 Period $2.
@12 Batch $2.
@14 AbsNo $3.
@18 Coder $2.
@20 ChartNo $10.
@30 RegNo $7.
@37 SecChartNo $10.
@47 MatNBChart $10.
@57 HCN $12.
@69 Postal $6.
@75 Rescode $7.
@82 Sex $1.
@83 ProvHCN $2.
@85 RFP $2.;
10-21-2012 12:47 PM
1.you can directly read compressed data without extracting them first using SASZIPAM.
Please refer the following sugi for the detailed usage.
2. Now too your question, whether we can read a password protected zip file.
Yes,This is also possible if the unzip/ uncompress software that you use in your environment allows this. In unix environment pkzip software allows this. I hope similarly winzip can do the same in windows environment.
10-23-2012 04:10 PM
Although I have not had it fail, I just recently learned that the SASZIPAM fileref engine is not recommended for use by SAS.