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

Hi,

I'm using below code to encrypt my passwords. It was working fine until several jobs started to use the same .txt file and It gave me error saying that the .txt file is in use.

Can someone suggest if there is a way in proc pwencode where I can create a macro variable with encrypted value without writing it to the .txt files?

%let uid = ididid;
%let pid = ididid;

filename pwfile '/uhyy/xx/pwd.txt';

filename ppw '/uhyy/xx/ppw.txt';

  proc pwencode in='My_pwd' out=pwfile;
run;

proc pwencode in='My_pwd' out=ppw;

run;


   options symbolgen;


%macro readpwd(filename,var);

  data _null_;
   infile &filename obs=1 length=l;
   input @;
   input @1 line $varying1024. l;
   call symput("&var",substr(line,1,l));
run;

%mend;
%readpwd(pwfile,pwd);
%readpwd(ppw,ppwd);

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Use the PATHNAME() function to get the filename. Or the FILENAME= option on the INFILE statement.

For EG there must be a method for downloading files, but if not then just read it into a dataset and download that.

View solution in original post

5 REPLIES 5
Tom
Super User Tom
Super User

Use the TEMP filename engine to insure that you get a unique file created.  The file will be created in the WORK directory.

filename pwfile temp;

proc pwencode in='My_pwd' out=pwfile;

run;

helloSAS
Obsidian | Level 7

Thank you!

Is there a way I can see the filename? and In EG how do i access work folder to see this file?

Tom
Super User Tom
Super User

Use the PATHNAME() function to get the filename. Or the FILENAME= option on the INFILE statement.

For EG there must be a method for downloading files, but if not then just read it into a dataset and download that.

helloSAS
Obsidian | Level 7

Thank you!

Peter_C
Rhodochrosite | Level 12

alternatively,

eliminate contention for a data file by writing it into a  SAS catalog in your WORK library.

It is similar to the TEMP filename engine but persists a bit longer.

filename encrp temp lrecl=2048 ;

Creates a reference to a new file that will be lost when the filename encrp is closed with something like:

filename encrp ;

filename encry catalog 'work.work.work.source' lrecl=2048 ;

defines the reference encry, pointing to the source-type catalog entry work.source in the SAS catalog work.work. The source entry will persist until the end of the SAS session (or someone deletes it or deletes the catalog)

It can be used as if it is a plain text file.

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
  • 5 replies
  • 1769 views
  • 3 likes
  • 3 in conversation