<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Prevent a macro from being 'put'? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Prevent-a-macro-from-being-put/m-p/559707#M156342</link>
    <description>&lt;P&gt;A few ideas to play with ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's only a partial solution, but take a look at PROC PWENCODE.&amp;nbsp; You can use an encoded version of your password.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on how smart the users are, you can set up your password in a way that it erases after using it one time.&amp;nbsp; For example, consider the code that you %INCLUDE:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options nosource;&lt;/P&gt;
&lt;P&gt;%let dbpass = Password123;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that you may need to add NOSOURCE2 to your list of options, to suppress writing %INCLUDEd code to the log.&amp;nbsp; Here is tricky way (modified after I first thought about it) so you don't need a macro variable (&amp;amp;DBPASS) at all:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro passw;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%global k;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%let k = %eval(&amp;amp;k+1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%if &amp;amp;k=1 %then Password123;&lt;/P&gt;
&lt;P&gt;%mend passw;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently when you use SAS to access Teradata, you need to specify something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;password = "&amp;amp;dbpass"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead, use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;password = "%passw"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The users won't even have a macro to examine.&amp;nbsp; If they try to execute %PASSW a second time in the same program, it generates nothing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 May 2019 16:24:37 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-05-17T16:24:37Z</dc:date>
    <item>
      <title>Prevent a macro from being 'put'?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prevent-a-macro-from-being-put/m-p/559690#M156331</link>
      <description>&lt;P&gt;Is there a way to set up a macro variable such that its contents cannot be '%put' into the SAS log?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, I have a password SAS program saved on my local drive that when '%include'd in my program, sets up my password for Teradata access:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options nosource;&lt;BR /&gt;%let dbpass = Password123;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In this way, I do not explicitly state my password in any analysis code, which is desired because I do not want other people on my team to know my Teradata password. Unfortunately, those ill-intended individuals who want to know my password can easily do so with this code:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put &amp;amp;dbpass. ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there a way to set up my password such that it cannot be revealed with a '%put' statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 15:22:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prevent-a-macro-from-being-put/m-p/559690#M156331</guid>
      <dc:creator>paulsonalec</dc:creator>
      <dc:date>2019-05-17T15:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent a macro from being 'put'?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prevent-a-macro-from-being-put/m-p/559702#M156339</link>
      <description>&lt;P&gt;The most simple method for protecting passwords is protecting the user, meaning that everyone has their own user for access. Sharing user-ID's is always a VERY BAD idea, securitywise.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know of no method to keep an existing macro variable from being used in a %put or a symget().&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 15:45:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prevent-a-macro-from-being-put/m-p/559702#M156339</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-17T15:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent a macro from being 'put'?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prevent-a-macro-from-being-put/m-p/559707#M156342</link>
      <description>&lt;P&gt;A few ideas to play with ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's only a partial solution, but take a look at PROC PWENCODE.&amp;nbsp; You can use an encoded version of your password.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on how smart the users are, you can set up your password in a way that it erases after using it one time.&amp;nbsp; For example, consider the code that you %INCLUDE:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options nosource;&lt;/P&gt;
&lt;P&gt;%let dbpass = Password123;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that you may need to add NOSOURCE2 to your list of options, to suppress writing %INCLUDEd code to the log.&amp;nbsp; Here is tricky way (modified after I first thought about it) so you don't need a macro variable (&amp;amp;DBPASS) at all:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro passw;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%global k;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%let k = %eval(&amp;amp;k+1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%if &amp;amp;k=1 %then Password123;&lt;/P&gt;
&lt;P&gt;%mend passw;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently when you use SAS to access Teradata, you need to specify something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;password = "&amp;amp;dbpass"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead, use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;password = "%passw"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The users won't even have a macro to examine.&amp;nbsp; If they try to execute %PASSW a second time in the same program, it generates nothing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 16:24:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prevent-a-macro-from-being-put/m-p/559707#M156342</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-05-17T16:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent a macro from being 'put'?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prevent-a-macro-from-being-put/m-p/559710#M156345</link>
      <description>&lt;P&gt;Thanks for the reply! This is clever, but limits the ability of the user to re-run the code in case that's desired. I'll add the options you suggested. It sounds like there's really no good answers to this problem&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 16:24:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prevent-a-macro-from-being-put/m-p/559710#M156345</guid>
      <dc:creator>paulsonalec</dc:creator>
      <dc:date>2019-05-17T16:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent a macro from being 'put'?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prevent-a-macro-from-being-put/m-p/559713#M156348</link>
      <description>&lt;P&gt;Yes, no ideal solution.&amp;nbsp; Note that I updated the code to make it simpler, and to prevent the user from gaining information by trying something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put _user_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There isn't even a macro variable to examine.&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 16:26:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prevent-a-macro-from-being-put/m-p/559713#M156348</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-05-17T16:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent a macro from being 'put'?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prevent-a-macro-from-being-put/m-p/559731#M156358</link>
      <description>&lt;P&gt;You have to put trust into the users you assign roles to.&lt;/P&gt;
&lt;P&gt;then if logging is required you need to use one of the suggestions above to remove those macro results or reset them to null after there need has been compleated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 17:39:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prevent-a-macro-from-being-put/m-p/559731#M156358</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-05-17T17:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent a macro from being 'put'?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prevent-a-macro-from-being-put/m-p/559831#M156393</link>
      <description>&lt;P&gt;The best method is to use authentication methods that do not use passwords.&lt;/P&gt;
&lt;P&gt;If you have SAS/BI (or whatever they call it now) where you can store credentials in metadata then use that.&lt;/P&gt;
&lt;P&gt;If you really must access systems where you have to use passwords then store the information in files. Make sure the files are properly secure.&amp;nbsp; For example by placing them in your .ssh directory that should be readable only by you.&amp;nbsp; Then you can use a macro to pull from the file without ever putting the value into a SAS macro variables. (Such as this one&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/fread.sas" target="_blank" rel="noopener"&gt;https://github.com/sasutils/macros/blob/master/fread.sas&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just make sure that MPRINT and other options that might display the value are off.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let opt_save=%sysfunc(getoption(mprint)) %sysfunc(getoption(macrogen));
%let opt_save=&amp;amp;opt_save %sysfunc(getoption(symbolgen));
options nomprint nomacrogen nosymbolgen;
libname mydb oracle path=mydb user=myuser pass="%fread(~/.ssh/mydb.txt,mode=3)" ;
options &amp;amp;opt_save;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For this usage you would probably want to make a version of FREAD() that only supported the MODE=3 option of returning the file results as the output of the macro.&amp;nbsp; You could also have that macro test that that the options are set properly to prevent displaying the password and fail when they are not.&lt;/P&gt;</description>
      <pubDate>Sat, 18 May 2019 00:14:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prevent-a-macro-from-being-put/m-p/559831#M156393</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-18T00:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: Prevent a macro from being 'put'?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prevent-a-macro-from-being-put/m-p/559834#M156395</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265905"&gt;@paulsonalec&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use authentication domains &lt;A href="http://support.sas.com/documentation/cdl/en/mcsecug/69854/HTML/default/viewer.htm#aboutum.htm#p18zm6n7c8eketn1ggs2opidsuzk" target="_blank" rel="noopener"&gt;http://support.sas.com/documentation/cdl/en/mcsecug/69854/HTML/default/viewer.htm#aboutum.htm#p18zm6n7c8eketn1ggs2opidsuzk&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or as another option found here:&amp;nbsp;&lt;A href="https://go.documentation.sas.com/?docsetId=acreldb&amp;amp;docsetTarget=n020g4ewg9ioe6n1rr3ihchwny4v.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://go.documentation.sas.com/?docsetId=acreldb&amp;amp;docsetTarget=n020g4ewg9ioe6n1rr3ihchwny4v.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;One way to protect connection information is by storing user name, password, and other connection options in a local environment&amp;nbsp;&lt;SPAN class="ng-scope" data-gloss-modified="" data-gloss-item="1"&gt;&lt;A class="glossLink ng-scope" href="https://go.documentation.sas.com/" target="_blank"&gt;&lt;SPAN class="xis-glossTerm ng-scope" data-gloss-term="1"&gt;variable&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;. Access to the DBMS is denied unless the correct user and password information is stored in a local environment variable. See the documentation for your DBMS to determine whether this alternative is supported.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 May 2019 01:43:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prevent-a-macro-from-being-put/m-p/559834#M156395</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-05-18T01:43:00Z</dc:date>
    </item>
  </channel>
</rss>

