<?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: .SAS file with text and pwencode in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910500#M359069</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Making a LOCAL macro variable does not work.&amp;nbsp; It just hides the value of the of the GLOBAL macro variable that the PROC creates.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Thanks Tom.&amp;nbsp; I had assumed that PROC PWENCODE executed in the DOSUBL side-session would write to the side-session global symbol table, allowing it to be returned to the main session local variable.&amp;nbsp; But sadly, looks like that is not the case.&amp;nbsp; I should have tested more.&amp;nbsp; Edited the code.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jan 2024 17:15:51 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2024-01-04T17:15:51Z</dc:date>
    <item>
      <title>.SAS file with text and pwencode</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910438#M359040</link>
      <description>&lt;P&gt;Hello. I am looking for a way to automate a password generation script I have to run very often. I basically need to insert some text, run pwencode, insert more text.&amp;nbsp; Any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EX:&lt;/P&gt;&lt;P&gt;text 1: %LET PASS =%STR(&lt;/P&gt;&lt;P&gt;pwencode&lt;/P&gt;&lt;P&gt;text2: );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 13:01:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910438#M359040</guid>
      <dc:creator>JMartin24</dc:creator>
      <dc:date>2024-01-04T13:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: .SAS file with text and pwencode</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910440#M359042</link>
      <description>&lt;P&gt;I'm having a hard time understanding your question.&amp;nbsp; Can you explain a bit more of your goal, and add to your example?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 13:29:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910440#M359042</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-01-04T13:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: .SAS file with text and pwencode</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910441#M359043</link>
      <description>&lt;P&gt;You can try this&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;filename pw temp;

proc pwencode in='mypass1' out=pw;
run;

data _null_;
    infile pw truncover;
    input pws $char100.;
    file print;
    call symput('password',pws);
run;

%put &amp;amp;=password;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Jan 2024 13:33:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910441#M359043</guid>
      <dc:creator>rudfaden</dc:creator>
      <dc:date>2024-01-04T13:33:39Z</dc:date>
    </item>
    <item>
      <title>Re: .SAS file with text and pwencode</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910443#M359044</link>
      <description>&lt;P&gt;Absolutely. I hope the below is more clarifying&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would want to be able to run a script/macro with the input to be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;text 1: %LET PASS =%STR(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FILENAME PW '\\Directory\\MYPASS.SAS'&lt;/P&gt;&lt;P&gt;PROC PWENCODE&lt;/P&gt;&lt;P&gt;IN = 'Password'&lt;/P&gt;&lt;P&gt;OUT = PW;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;text2: );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With the ouput to be a singular sas file that contains:&lt;/P&gt;&lt;P&gt;%LET PASS =%STR(EncryptedPasswordStringFromPWENCODE);&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 13:35:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910443#M359044</guid>
      <dc:creator>JMartin24</dc:creator>
      <dc:date>2024-01-04T13:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: .SAS file with text and pwencode</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910448#M359045</link>
      <description>&lt;P&gt;Sorry, I'm still not following.&amp;nbsp; I don't understand what text2 represents.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your goal is to create a macro variable that has the value of the encoded password, PROC PWENCODE does that automatically.&amp;nbsp; It creates a global macro variable, _PWENCODE. So you can do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc pwencode in='mypassword' ;
run ;
%let pass=&amp;amp;_PWencode ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And that will store the encoded password in the macro variable PASS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to create function that will return an encoded password, you could use DOSUBL to create a function-like macro that returns an encoded password, e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro pwencode(password);
  %local rc ;
  %let rc=%sysfunc(dosubl(%nrstr(
    proc pwencode in="&amp;amp;password" ;
    run ;
  )));
  &amp;amp;_PWencode
%mend;

%let mypass=%pwencode(mypassword) ;
%put &amp;amp;=mypass ;

%let yourpass=%pwencode(yourpassword) ;
%put &amp;amp;=yourpass ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So if the goal is to get an encoded password string into a macro variable, you don't need to generate a .sas file with a %LET statement in it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does that help?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT:&lt;/P&gt;
&lt;P&gt;In the macro, I added _PWENCODE to the %local statement. This avoids the macro variable _PWENCODE from being written to the global symbol table of your main session.&amp;nbsp; That said, I'm not necessarily recommending the DOSUBL approach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another Edit:&lt;/P&gt;
&lt;P&gt;Removed _PWENCODE from the %local statement, cuz it broke stuff. : ) Apparently when PROC PWENCODE runs in the DOSUBL side-session, it still creates the macro variable&amp;nbsp;_PWENCODE in the main session global table. Unfortunate.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 17:12:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910448#M359045</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-01-04T17:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: .SAS file with text and pwencode</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910497#M359066</link>
      <description>&lt;P&gt;Making a LOCAL macro variable does not work.&amp;nbsp; It just hides the value of the of the GLOBAL macro variable that the PROC creates.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 17:04:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910497#M359066</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-01-04T17:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: .SAS file with text and pwencode</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910498#M359067</link>
      <description>&lt;P&gt;You have not parametrized your inputs efficiently.&lt;/P&gt;
&lt;P&gt;Sounds like your output is a file.&lt;/P&gt;
&lt;P&gt;So your inputs are a filename and a password (a string).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro pwencode(password,filename);
filename pwencode temp;
proc pwencode in="&amp;amp;password" out=pwencode;
run;
filename pwencode;
data _null_;
  file "&amp;amp;filename";
  put '%let pass=' "&amp;amp;_PWencode" ';' ;
run;
%symdel _pwencode;
%mend pwencode ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Let's try it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename test temp;
%pwencode(password=mypass,filename=%sysfunc(pathname(test)))
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;%let pass={SAS002}E2B3D742098C5EEE300EF38F;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Jan 2024 17:15:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910498#M359067</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-01-04T17:15:16Z</dc:date>
    </item>
    <item>
      <title>Re: .SAS file with text and pwencode</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910500#M359069</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Making a LOCAL macro variable does not work.&amp;nbsp; It just hides the value of the of the GLOBAL macro variable that the PROC creates.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Thanks Tom.&amp;nbsp; I had assumed that PROC PWENCODE executed in the DOSUBL side-session would write to the side-session global symbol table, allowing it to be returned to the main session local variable.&amp;nbsp; But sadly, looks like that is not the case.&amp;nbsp; I should have tested more.&amp;nbsp; Edited the code.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 17:15:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910500#M359069</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-01-04T17:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: .SAS file with text and pwencode</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910541#M359077</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Making a LOCAL macro variable does not work.&amp;nbsp; It just hides the value of the of the GLOBAL macro variable that the PROC creates.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hi Again&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; et al,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This has been bugging me off-an-on during the day, because I remember I did get my DOSUBL function-style macro working like I wanted at one point this morning before posting.&amp;nbsp; Now at the end of the day I came back to it, and realized the DOSUBL problem I hit.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro pwencode(password);
  %local rc _pwencode;
  %let rc=%sysfunc(dosubl(%nrstr(
    proc pwencode in="&amp;amp;password" ;
    run ;
  )));
  &amp;amp;_PWencode
%mend;

%let mypass=%pwencode(mypassword) ;
%put _user_ ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;By my understanding of the rules of DOSUBL magic, it 'should' work.&amp;nbsp; I think PROC PWENCODE 'should' create the macro variable _PWENCODE in the side-session global symbol table, and then return the value of the macro variable to the main session local symbol table when DOSUBL completes.&amp;nbsp; But that does not happen, instead PROC PWENCODE creates the macro variable _PWENCODE in the main session global symbol table.&amp;nbsp; So this code does not work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, if you use a %LET statement in the DOSUBL block to create a global macro variable named _PWENCODE in the side session before calling PROC PWENCODE, then PROC PWENCODE will write to that macro variable.&amp;nbsp; And this allows the function-style macro to work like I had intended.&amp;nbsp; It avoids creating a global macro variable in the main session symbol table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro pwencode(password);
  %local rc _pwencode; 
  %let rc=%sysfunc(dosubl(%nrstr(
    %let _pwencode= ; %*Create global macro variable in side session, PROC PWENCODE will assign it a value ;
    proc pwencode in="&amp;amp;password" ;
    run ;
  )));
  &amp;amp;_PWencode
%mend;

%let mypass1=%pwencode(aaa) ;
%let mypass2=%pwencode(bbb) ;
%put _user_ ;&lt;/CODE&gt;&lt;/PRE&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;
&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>Thu, 04 Jan 2024 21:46:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-file-with-text-and-pwencode/m-p/910541#M359077</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-01-04T21:46:47Z</dc:date>
    </item>
  </channel>
</rss>

