<?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: Formatting a Macro Variable with Put? in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419090#M3864</link>
    <description>&lt;P&gt;There is no %putn macro function, the data step function needs to be wrapped with %sysfunc:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let time = %sysfunc(datetime());
%let time = %sysfunc(putn(&amp;amp;time, datetime20));
%put time=&amp;amp;time;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;24         %let time = %sysfunc(datetime());
25         %let time = %sysfunc(putn(&amp;amp;time, datetime20));
26         %put time=&amp;amp;time;
time=07DEC2017:09:31:56
&lt;/PRE&gt;</description>
    <pubDate>Thu, 07 Dec 2017 08:34:12 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-12-07T08:34:12Z</dc:date>
    <item>
      <title>Formatting a Macro Variable with Put?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419039#M3856</link>
      <description>&lt;P&gt;Hello. I wonder if there is anyway I can format a macro variable in this case.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
	Time=datetime();
	submit Time;
		%put Time=&amp;amp;Time;
	endsubmit;
	print Time[format=datetime20.];
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It seems the variable Time is formatted well with print but not with %put.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 02:09:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419039#M3856</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2017-12-07T02:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a Macro Variable with Put?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419061#M3857</link>
      <description>&lt;P&gt;Not directly, but indirectly is easy:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let time2 = %putn(&amp;amp;time, datetime20);&lt;/P&gt;
&lt;P&gt;%put Time2=&amp;amp;time2;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 03:47:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419061#M3857</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-12-07T03:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a Macro Variable with Put?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419063#M3858</link>
      <description>Thanks, but it seems it is not working inside the submit-endsubmit sentences.</description>
      <pubDate>Thu, 07 Dec 2017 03:53:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419063#M3858</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2017-12-07T03:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a Macro Variable with Put?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419064#M3859</link>
      <description>&lt;P&gt;Ah, that's right.&amp;nbsp; The macro statements are not part of the PROC.&amp;nbsp; You could try it this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let time= %sysfunc(datetime(), datetime20.);&lt;/P&gt;
&lt;P&gt;%put time=&amp;amp;time;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can't test it until tomorrow, but give it a shot and we'll see what happens.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 03:56:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419064#M3859</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-12-07T03:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a Macro Variable with Put?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419066#M3860</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="171206.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17060i0B8550980469A39F/image-size/large?v=v2&amp;amp;px=999" role="button" title="171206.png" alt="171206.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This does not work as well. Must I consider another way rather than the submit-endsubmit sentences?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 04:02:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419066#M3860</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2017-12-07T04:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a Macro Variable with Put?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419067#M3861</link>
      <description>&lt;P&gt;Entirely separate from IML, this should be workable.&amp;nbsp; I'm splitting it out in steps, since I can't test it myself so this might help isolate where things break down (if they do break down):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let time = %sysfunc(datetime());&lt;/P&gt;
&lt;P&gt;%let time = %putn(&amp;amp;time, datetime20);&lt;/P&gt;
&lt;P&gt;%put time=&amp;amp;time;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 04:06:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419067#M3861</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-12-07T04:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a Macro Variable with Put?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419083#M3862</link>
      <description>Sorry but this is not successful too. This prints time=%putn(numbers,datetime20.) instead.</description>
      <pubDate>Thu, 07 Dec 2017 06:43:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419083#M3862</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2017-12-07T06:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a Macro Variable with Put?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419089#M3863</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/173881"&gt;@Junyong&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello. I wonder if there is anyway I can format a macro variable in this case.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
	Time=datetime();
	submit Time;
		%put Time=&amp;amp;Time;
	endsubmit;
	print Time[format=datetime20.];
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It seems the variable Time is formatted well with print but not with %put.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Usual miscomprehension about the macro facility. The macro &lt;STRONG&gt;PRE&lt;/STRONG&gt;processor evaluates the %put Statement &lt;EM&gt;before&lt;/EM&gt; proc iml runs (while the code is being fetched), and will therefore have no access to the IML variable. It will look for a &lt;EM&gt;previously defined macro variable&lt;/EM&gt; time, which most probably isn't there at all.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 08:30:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419089#M3863</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-12-07T08:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a Macro Variable with Put?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419090#M3864</link>
      <description>&lt;P&gt;There is no %putn macro function, the data step function needs to be wrapped with %sysfunc:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let time = %sysfunc(datetime());
%let time = %sysfunc(putn(&amp;amp;time, datetime20));
%put time=&amp;amp;time;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;24         %let time = %sysfunc(datetime());
25         %let time = %sysfunc(putn(&amp;amp;time, datetime20));
26         %put time=&amp;amp;time;
time=07DEC2017:09:31:56
&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Dec 2017 08:34:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419090#M3864</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-12-07T08:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a Macro Variable with Put?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419095#M3865</link>
      <description>&lt;P&gt;But it seems MACRO can read IML variables with submit-endsubmit sentences.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
	do IMLVariable=1 to 30;
		submit IMLVariable;
			%put &amp;amp;IMLVariable;
		endsubmit;
	end;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;No MACRO variable exists here.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 08:58:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419095#M3865</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2017-12-07T08:58:54Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a Macro Variable with Put?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419096#M3866</link>
      <description>&lt;P&gt;Thanks. It should have been putn rather than %putn.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
	Time=datetime();
	submit Time;
		%put Time=%sysfunc(putn(&amp;amp;Time,datetime20.));
	endsubmit;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This solves everything.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 09:01:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419096#M3866</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2017-12-07T09:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a Macro Variable with Put?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419098#M3867</link>
      <description>&lt;P&gt;You are right. I'm not well versed with proc iml yet. IML supplies its variables as macro variables to the SAS processor when it executes a submit block.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 09:10:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419098#M3867</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-12-07T09:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a Macro Variable with Put?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419118#M3868</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You seem to have solved the formatting problem, so that's good.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to point out a conceptual&amp;nbsp;problem in this thread. &lt;A href="http://go.documentation.sas.com/?docsetId=imlug&amp;amp;docsetTarget=imlug_procs_sect003.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en" target="_self"&gt;As discussed in the SAS/IML&amp;nbsp;documentation&lt;/A&gt;, NO MACRO VARIABLE is involved in this use of the SUBMIT block. The doc says:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS® Help Center: Passing Parameters from SAS/IML Matrices&lt;!-- Place favicon.ico and apple-touch-icon.png in the root directory --&gt; &lt;!-- build:css(.) styles/vendor.css --&gt;&lt;EM&gt; &lt;!-- bower:css --&gt; &lt;!-- endbower --&gt; &lt;!-- endbuild --&gt; &lt;!-- endbuild --&gt; &lt;!--support site DTM tag, double check syntax and uncomment prior to going live--&gt; &lt;!--&amp;lt;script src="//assets.adobedtm.com/a4a4268256930a29de311efab04f43cf44db167b/satelliteLib-392eedeb8633e1cc249f4de8df2bb2cfb4073228.js"&gt;&amp;lt;/script&amp;gt;--&gt;&lt;!-- ngRepeat: stylesheet in stylesheets track by $index | orderBy: 'weight' --&gt;&lt;!-- end ngRepeat: stylesheet in stylesheets track by $index | orderBy: 'weight' --&gt;&lt;!-- end ngRepeat: stylesheet in stylesheets track by $index | orderBy: 'weight' --&gt;&lt;!-- end ngRepeat: stylesheet in stylesheets track by $index | orderBy: 'weight' --&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;DIV id="app" class="app h-full ng-scope"&gt;
&lt;DIV class="app-wrapper ng-scope"&gt;
&lt;DIV id="app-bottom-wrapper" class="app-b-wrapper"&gt;
&lt;DIV id="document-panel" class="pos-r h-full"&gt;
&lt;DIV class="overflow-h ng-scope"&gt;
&lt;DIV id="document" class="document scrollable ng-scope"&gt;
&lt;DIV id="pageContent" class="document-body wrapper" lang="en" tabindex="0"&gt;
&lt;DIV class="xis-refProc ng-scope"&gt;
&lt;SECTION id="imlug.procs.parammatrices" class="aa-section"&gt;
&lt;P&gt;&lt;EM&gt;You can list the names of SAS/IML matrices in the SUBMIT statement and refer to the contents of those matrices inside the SUBMIT block. The syntax is reminiscent of the syntax for macro variables: an ampersand (&amp;amp;) preceding an expression means "substitute the value of the expression." However, the substitution takes place before the SUBMIT block is sent to the SAS System;&lt;STRONG&gt; no macro variables are actually created.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For more about parameter substitution and SUBMIT blocks, see&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2013/06/03/passing-values-into-procedures.html" target="_self"&gt;"Passing values from PROC IML into SAS procedures"&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;or watch the video&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2011/10/24/video-calling-sas-procedures-from-the-sasiml-language.html" target="_self"&gt;"Calling SAS procedures from the SAS/IML language"&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/SECTION&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 07 Dec 2017 10:35:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419118#M3868</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-12-07T10:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a Macro Variable with Put?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419119#M3869</link>
      <description>&lt;P&gt;PS. Another way to format a value is to use the PUT statement in a DATA step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;submit Time;&lt;BR /&gt;data _null_;&lt;BR /&gt;Time = &amp;amp;Time;&lt;BR /&gt;put Time datetime20.;&lt;BR /&gt;run;&lt;BR /&gt;endsubmit;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 10:36:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419119#M3869</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-12-07T10:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a Macro Variable with Put?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419120#M3870</link>
      <description>&lt;P&gt;Ah, that's like it was in SAS SCL.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 10:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Formatting-a-Macro-Variable-with-Put/m-p/419120#M3870</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-12-07T10:38:22Z</dc:date>
    </item>
  </channel>
</rss>

