0

I have an autoexec file that encrypts my password when I'm connecting to different servers....the code looks as follows:

%global wspwd ewspwd hpwd ehpwd ;

/* Enter WORKSTATION Password Below */
filename ewspwdfl "/home/&sysuserid./ewspwd.txt" ;
proc pwencode in=’XXXXXXXX’ out=ewspwdfl ; run ;
data _null_ ;
    infile ewspwdfl obs=1 length=l ;
    input @ ;
    input @1 line1 $varying1024. l ;
    call symput('ewspwd',cats(substr(line1,1,l))) ;
    call symput('wspwd',cats(‘XXXXXXXX’)) ;
run ; 

My question is: why is

input @ ; 

included and why

input @1 line1 $varying1024. l ;

doesn't suffice.

Whenever I have created datasets with SAS I have never had to include "input @;" in my statement. I just simply write something along the lines of:

input @1 firstname $ @15 lastname $ @30 date mmddyy6.;
DukeLuke
  • 315
  • 6
  • 26
  • Why do you think it is needed? Did you try removing it and did that make it not work? In what way did it not work? – Tom Jul 20 '16 at 16:22
  • I had this set up... I was thinking I didn't need it, but I'm not sure all of the contingencies that rely on this autoexec file so I haven't changed anything. People I have talked to don't know it's purpose... – DukeLuke Jul 20 '16 at 17:41
  • You need it for some of the INFILE options to get populated. Such as FILENAME= option or EOV= option. But I don't think you need it for the LENGTH= option that your code it using. – Tom Jul 20 '16 at 19:25
  • I'm confused as to why you need this. Wouldn't SAS understand that you have a variable and that it's value begins @1??? I've never had to solely use "Input @;" then state input again.. – DukeLuke Jul 20 '16 at 19:45
  • FYI - pwencode is not secure. See http://stackoverflow.com/questions/8157160/odbc-password-security-in-sas – Robert Penridge Jul 21 '16 at 15:48
  • how is that true? this is in my HOME folder which is locked by anyone except me. so no one can even see my autoexec file or my encrypted password. all programs I run retrieve my encrypted password under my /home folder... – DukeLuke Jul 21 '16 at 19:00

1 Answers1

2

You don't need it for that data step. You could simplify it to.

data _null_ ;
  infile ewspwdfl obs=1 TRUNCOVER ;
  input line1 $CHAR1024. ;
  call symputX('ewspwd',line1);
  call symputX('wspwd',‘XXXXXXXX’) ;
run ; 

Using input @ is a good way to create a program where you want to read different lines using different input statements. You could test the content of the _infile_ variable and execute different parts of the data step based on what is read.

It is also useful when using the EOV= option on the INFILE statement to detect when you are starting to read from a new file, since it is not set until you begin reading the new file. So the INPUT @ gets SAS to begin reading so that the EOV variable is set, but keeps the line waiting for your real INPUT statement to read later.

The @1 is useful if you want to read the same columns over again into different variables. For example you might want to read the first few characters as a string and then test them and based on what you find re-read as a number or a date.

Tom
  • 47,574
  • 2
  • 16
  • 29
  • "Using input @ is a good way to create a program where you want to read different lines using different input statements. " are you referring to formatted, column, list and name input? – DukeLuke Jul 21 '16 at 13:04
  • It is useful to let you write code that reads complicated junk like the report that some wants to read in this recent question. https://stackoverflow.com/questions/38503002/import-unsorted-data-from-a-notepad-file-txt-into-sas – Tom Jul 21 '16 at 14:02