<?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: nested %sysfunc in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/nested-sysfunc/m-p/769813#M244126</link>
    <description>Hi, thanks for your answer.&lt;BR /&gt;But i really want to keep gen value as rand('uniform') -&amp;gt; With single quotes &lt;BR /&gt;and use compress when executing it in the %put statement.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
    <pubDate>Thu, 23 Sep 2021 08:25:08 GMT</pubDate>
    <dc:creator>indox</dc:creator>
    <dc:date>2021-09-23T08:25:08Z</dc:date>
    <item>
      <title>nested %sysfunc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/nested-sysfunc/m-p/769224#M244033</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let gen=(rand('uniform'));
%put %sysfunc(compress(&amp;amp;gen,%str(%')));&lt;/PRE&gt;
&lt;P&gt;This is my code above. I want the second line to execute the %put rand(uniform) and give me a number instead of returning then string "(rand(uniform))".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for help.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Sep 2021 15:51:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/nested-sysfunc/m-p/769224#M244033</guid>
      <dc:creator>indox</dc:creator>
      <dc:date>2021-09-22T15:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: nested %sysfunc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/nested-sysfunc/m-p/769364#M244036</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/135569"&gt;@indox&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want repeated %PUT statements to write the same number (once it has been created with the %LET statement) as shown in the log below&lt;/P&gt;
&lt;PRE&gt;879  %let gen=%sysfunc(rand(uniform));
880  %put &amp;amp;gen;
0.90237695327959
881  %put &amp;amp;gen;
0.90237695327959&lt;/PRE&gt;
&lt;P&gt;or different numbers?&lt;/P&gt;
&lt;PRE&gt;883  %macro newgen; %sysfunc(rand(uniform)); %mend newgen;
884  %put %newgen;
0.68273608107119
885  %put %newgen;
0.54702847357839&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Sep 2021 16:25:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/nested-sysfunc/m-p/769364#M244036</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-09-22T16:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: nested %sysfunc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/nested-sysfunc/m-p/769813#M244126</link>
      <description>Hi, thanks for your answer.&lt;BR /&gt;But i really want to keep gen value as rand('uniform') -&amp;gt; With single quotes &lt;BR /&gt;and use compress when executing it in the %put statement.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 23 Sep 2021 08:25:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/nested-sysfunc/m-p/769813#M244126</guid>
      <dc:creator>indox</dc:creator>
      <dc:date>2021-09-23T08:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: nested %sysfunc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/nested-sysfunc/m-p/769817#M244129</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/135569"&gt;@indox&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi, thanks for your answer.&lt;BR /&gt;But i really want to keep gen value as rand('uniform') -&amp;gt; With single quotes &lt;BR /&gt;and use compress when executing it in the %put statement.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In your first post you stated that you want numbers. Numbers do not contain quotes.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 08:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/nested-sysfunc/m-p/769817#M244129</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-23T08:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: nested %sysfunc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/nested-sysfunc/m-p/769850#M244136</link>
      <description>&lt;P&gt;You could use a second macro variable to avoid nested %SYSFUNC calls that don't work as you intended:&lt;/P&gt;
&lt;PRE&gt;14   %let gen=rand('uniform');
15   %let gen2=%sysfunc(compress(&amp;amp;gen,%str(%')));
16   %put %sysfunc(&amp;amp;gen2);
0.16552548436447
17   %put %sysfunc(&amp;amp;gen2);
0.13993664132431&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Sep 2021 09:31:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/nested-sysfunc/m-p/769850#M244136</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-09-23T09:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: nested %sysfunc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/nested-sysfunc/m-p/769851#M244137</link>
      <description>&lt;P&gt;Happy macro galore&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* step 1 */
%put %sysfunc(rand(uniform));

/* step 2 */
%let gen=rand(uniform);
%put %sysfunc(&amp;amp;gen);

/* step 3 */
%put %sysfunc(compress(%sysfunc(&amp;amp;gen)));

/* step 4 */
%put %nrbquote(')%sysfunc(compress(%sysfunc(&amp;amp;gen)))%nrbquote(');
%put %unquote(%nrbquote(')%sysfunc(compress(%sysfunc(&amp;amp;gen)))%nrbquote('));

/* alternative */
%let gen=rand(uniform);
%put %unquote(%cmpres(%nrbquote(')%sysfunc(&amp;amp;gen)%nrbquote(')));

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log&lt;/P&gt;
&lt;PRE&gt;31         /* step 1 */
32         %put %sysfunc(rand(uniform));
0.97763167554512
33         
34         /* step 2 */
35         %let gen=rand(uniform);
36         %put %sysfunc(&amp;amp;gen);
0.39544295193627
37         
38         /* step 3 */
39         %put %sysfunc(compress(%sysfunc(&amp;amp;gen)));
0.89240621402859
40         
41         /* step 4 */
42         %put %nrbquote(')%sysfunc(compress(%sysfunc(&amp;amp;gen)))%nrbquote(');
'0.25708963023498'
43         %put %unquote(%nrbquote(')%sysfunc(compress(%sysfunc(&amp;amp;gen)))%nrbquote('));
'0.006260557333'
44         
45         /* alternative */
46         %let gen=rand(uniform);
47         %put %unquote(%cmpres(%nrbquote(')%sysfunc(&amp;amp;gen)%nrbquote(')));
'0.15496678999625'
48         &lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Sep 2021 09:32:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/nested-sysfunc/m-p/769851#M244137</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-09-23T09:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: nested %sysfunc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/nested-sysfunc/m-p/769877#M244158</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your requirements are confusing.&amp;nbsp; You should not need to remove quotes on the %PUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The main problem here is that the quote marks are not part of the macro language, and you have an extra set of parentheses.&amp;nbsp; If you want to store the code to generate a random number in a macro variable, the easiest way would be to change the value of the macro variable so that the code can be executed by %sysfunc:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1    %let gen=rand(uniform) ; *This stores code in a macro variable ;
2    %put &amp;amp;=gen ;
GEN=rand(uniform)
3    %put %sysfunc(&amp;amp;gen) ;    *This uses sysfunc to execute the stored code ;
0.53809128166176
4    %put %sysfunc(&amp;amp;gen) ;
0.37165963975712
&lt;/PRE&gt;
&lt;P&gt;If you cannot change the value of gen for some reason, then as others have pointed out, you can create a new macro var with the correct code:&lt;/P&gt;
&lt;PRE&gt;1    %let gen=(rand('uniform'));  *This value has unwanted quotes and extra set of parentheses ;
2    %put &amp;amp;=gen ;
GEN=(rand('uniform'))
3
4    *remove the parentheses ;
5    %let gen2=%sysfunc(substr(&amp;amp;gen,2,%sysfunc(length(&amp;amp;gen))-2)) ;
6    %put &amp;amp;=gen2 ;
GEN2=rand('uniform')
7
8    *remove the quotes ;
9    %let gen3=%sysfunc(compress(&amp;amp;gen2,%str(%')));
10   %put &amp;amp;=gen3 ;
GEN3=rand(uniform)
11
12   %put %sysfunc(&amp;amp;gen3);
0.639510035282
13   %put %sysfunc(&amp;amp;gen3);
0.41172609385102
&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Sep 2021 12:18:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/nested-sysfunc/m-p/769877#M244158</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2021-09-23T12:18:45Z</dc:date>
    </item>
  </channel>
</rss>

