sassoftware / vscode-sas-extension

This SAS Extension for Visual Studio Code provides support for the SAS language, including features such as SAS syntax highlighting, code completion, hover help, code folding, outline, SAS code snippets and run SAS code.
https://sassoftware.github.io/vscode-sas-extension/
Apache License 2.0
105 stars 44 forks source link

Prompt user for password input when querying encrypted SAS datasets #1009

Open gah-bo opened 1 month ago

gah-bo commented 1 month ago

Is your feature request related to a problem? Please describe. Yes - ERROR when trying to query a password protected SAS Dataset

Describe the solution you'd like Prompt user for password; not sure of best way, but SAS 9.4 (Local) does this with a pop-up window stating the name of the dataset that requires password.

Describe alternatives you've considered Including password argument explicitly (example: FROM dataset (encryptkey=XXXX)) - I consider this bad practice though so it's not an alternative for me.

Additional context Would be very useful for us that work with PHI datasets, and I'm sure other domains too...

Environment SAS 9.4 (Local)

snlwih commented 3 weeks ago

@gah-bo , when you mention AS 9.4 (Local) you are talking about SAS Display Manager, right? And you are talking about the dataset options ALTER=/PW=/READ=/WRITE=, correct?

Have you considered creating a macro variable to contain the dataset password? A not uncommon approach is as follows:

  1. setup.sas

    /* Put read-password in a SAS macro variable */
    %let READPW=SAS123;
  2. main.sas

    /* Password will be blotted out in the SAS log */
    proc print data=lib.dataset_with_readpw(read=&READPW);
    run;

Would this be an acceptable workaround for you?

gah-bo commented 2 weeks ago

@snlwih Thanks for following up on this! I will try to reply quicker next time, it was a long week...

when you mention AS 9.4 (Local) you are talking about SAS Display Manager, right?

I am not sure, sorry...I use SAS in my current employment position but barely, and had not ever used it before that. I can say it looks identical to this, and the name of the program / version when I click Help is SAS 9.4 144474015_orig 1 (not my own screenshot as it was less tedious to just find one online...but I can take a screenshot on my actual work PC if needed)

And you are talking about the dataset options ALTER=/PW=/READ=/WRITE=, correct?

Hmm no; I am not familiar with those options (I've probably used READ/WRITE).

The one we use is encryptkey. We only use it on PROC SQL but it seems its available for data steps as well?

snlwih commented 2 weeks ago

@gah-bo, the screenshot indeed shows SAS 9 Display Manager System (aka. DMS).

Have you looked into my suggestion for storing the password in a macro variable and defining that macro variable in a separate file? This would allow you to share your data processing code and SAS log without that password being visible. Wouldn't that be a workable solution?

Your main.sas file could then start with the following SAS code:

options nomprint nosource2;
%include "<path-to-setup.sas>"; /* setup.sas is in a location that can only be read by authorized staff */