| knowledge-database (beta) |
 |
Current group: comp.soft-sys.sas
Re: Password protect a large number of files
|
|
 | | From: | Pardee, Roy | | Subject: | Re: Password protect a large number of files | | Date: | 21 Jan 05 20:39:09 GMT |
|
|
 | If all else fails you can do this w/a macro. Here's one I wrote that loops through all dsets in a lib & removes a specified identifier--it can probably easily be modified to the proc datasets call you need.
Another (easier?) way to go would be to do this at the OS level--so frx if you're on windows, set the files' read-only attributes.
HTH,
-Roy /********************************************* * Removes the identifier specified in &OldIDVar in * every dataset found in the library specified in * &Lib, and replaces it with the identifier specified * in &NewIDVar. * * Meant to be called after the %DeIDDset, which generates * a crosswalk dataset. * * Sample call: * * %DeIDLib(XWalkNam = XWalk The 1-part name of a crosswalk dset (assumed to live in &Lib) * , Lib = PHE The libname of the library you want cleaned out * , OldIDVar = CHSID The name of the ID variable you want removed. * , NewIDVar = StudyID The name of the new ID variable you want to replace &OldIDVar with. * ) ; * *********************************************/ %macro DeIDLib(XWalkNam /* The name of a crosswalk dset (assumed to live in &Lib) */ , Lib /* The libname of the library you want cleaned out */ , OldIDVar = CHSID /* The name of the ID variable you want removed. */ , NewIDVar = StudyID /* The name of the new ID variable you want to replace &OldIDVar with.*/ ) ; proc sql ; * Gather a list of all dsets that have the old identifier in them ; select distinct memname into :dset1-:dset999 from dictionary.columns where libname = "%upcase(&LIB)" AND memtype = 'DATA' AND upcase(name) in ("&OldIDVar") AND memname ne "%upcase(&XWalkNam)" ; %let NumDS = &SQLOBS ; * Now replace the old id in each dset with the new id ; %do i = 1 %to &NumDS ; %let ThisDs = &lib..&&dset&i ; %put Working on &ThisDs ; create table &ThisDS(drop = &OldIDVar) as select x.&NewIDVar, t.* from &ThisDS as t LEFT JOIN &Lib..&XWalkNam as x on x.&OldIDVar = t.&OldIDVar ; %end ; * Verify that there are now no dsets in &Lib that still contain &OldIDVar ; title1 "WARNING--THESE DSETS STILL CONTAIN &OLDIDVAR!!!" ; select distinct memname from dictionary.columns where libname = "%upcase(&LIB)" AND memtype = 'DATA' AND upcase(name) in ("&OldIDVar") AND memname ne "%upcase(&XWalkNam)" ; title1 ; %if &SQLOBS > 0 %then %do ; %put ; %put PROBLEM--&SQLOBS datasets still contain &OldIDVar!!! See the listing file for their names!!! ; %put ; %end ; %else %do ; %put ; %put Success! All datasets in &Lib (except for &XWalkNam) have had &OldIDVar replaced with &NewIDVar. ; %put ; %end ; quit ; %mend ;
-----Original Message----- From: SAS(r) Discussion on behalf of Ya Huang Sent: Fri 1/21/2005 12:28 PM To: SAS-L@LISTSERV.UGA.EDU Cc: Subject: Re: Password protect a large number of files
You may consider create another folder and create views for all the data sets in the original folder and save them in the view folder, and change the libname to the view folder.
On Fri, 21 Jan 2005 15:23:16 -0500, Pat Moore wrote:
>SAS Gurus, > >I have a directory of files which I use frequently and want to avoid >accidently modifying any of them. Encryption is not an issue here - just a >way to keep myself from ham-handedly deleting something. Is there a way to >add the same password to all of these files without having to modify them >one at a time? I have learned to apply a pw= option in the data step when I >create new files, but I want to issue something like: > >%let password=mypass; >proc datasets library=mylib; >modify * (pw=&password); >run; > >and have it apply the same password at the read, write, and alter levels to >all the files in mylib. Problem is, the modify option only works on one >file at a time. > >A macro, maybe? Something simpler? > >Pat in Juneau AK
|
|
|
| | |
|
 |