<?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: Saving Formatted Text to a Macro Variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Saving-Formatted-Text-to-a-Macro-Variable/m-p/239573#M44090</link>
    <description>&lt;P&gt;My question would be, why do you need to do this in macro language? &amp;nbsp;There doesn't seem to be any value, and simple Base SAS would do this just fine:&lt;/P&gt;
&lt;PRE&gt;data _null_;
   call symput('currentFiscalPeriod',input(month(date()),fiscal_period_format.);
run;&lt;/PRE&gt;
&lt;P&gt;Saying that, not sure why you need the format either, why does z2. not suffice?&lt;/P&gt;</description>
    <pubDate>Wed, 16 Dec 2015 17:02:29 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2015-12-16T17:02:29Z</dc:date>
    <item>
      <title>Saving Formatted Text to a Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Saving-Formatted-Text-to-a-Macro-Variable/m-p/239526#M44076</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I save the marked line as a macro variable containing text like 06?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;PROC FORMAT;&lt;BR /&gt;value Fiscal_Period_Format&lt;BR /&gt;1='07'&lt;BR /&gt;2='08'&lt;BR /&gt;3='09'&lt;BR /&gt;4='10'&lt;BR /&gt;5='11'&lt;BR /&gt;6='12'&lt;BR /&gt;7='01'&lt;BR /&gt;8='02'&lt;BR /&gt;9='03'&lt;BR /&gt;10='04'&lt;BR /&gt;11='05'&lt;BR /&gt;12='06';&lt;BR /&gt;RUN;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%macro setDates();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %let currentFiscalPeriod = input(month(date()), Fiscal_Period_Format.); /*this line blows up*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %put &amp;amp;currentFiscalPeriod;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %mend;&lt;BR /&gt;%setDates();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 15:11:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Saving-Formatted-Text-to-a-Macro-Variable/m-p/239526#M44076</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2015-12-16T15:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: Saving Formatted Text to a Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Saving-Formatted-Text-to-a-Macro-Variable/m-p/239532#M44079</link>
      <description>&lt;P&gt;You need some %sysfunc() functions in order to do some of those functions as they are not macro functions.&amp;nbsp; Try the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
	value fiscal_period_format
		1='07'
		2='08'
		3='09'
		4='10'
		5='11'
		6='12'
		7='01'
		8='02'
		9='03'
		10='04'
		11='05'
		12='06';
run;


%macro setDates;
	%let currFiscalPd=%sysfunc(month(%sysfunc(date())),fiscal_period_format.);
	%put &amp;amp;currFiscalPd;
%mend;
%setDates;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Dec 2015 15:23:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Saving-Formatted-Text-to-a-Macro-Variable/m-p/239532#M44079</guid>
      <dc:creator>dcruik</dc:creator>
      <dc:date>2015-12-16T15:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: Saving Formatted Text to a Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Saving-Formatted-Text-to-a-Macro-Variable/m-p/239533#M44080</link>
      <description>&lt;P&gt;This program has several issues (don't we all?), but all can be fixed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Macro language does not execute DATA step functions.&lt;/LI&gt;
&lt;LI&gt;Even if you overcome issue #1, macro language would not execute PUT or INPUT functions.&lt;/LI&gt;
&lt;LI&gt;You are attempting to use INPUT with a format, when PUT would be the right tool.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;%SYSFUNC is required to allow macro language to execute a DATA step function.&amp;nbsp; Unfortunately, that clutters the program significantly.&amp;nbsp; Try it this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let currentFiscalPeriod = %sysfunc(putn(%sysfunc(month(%sysfunc(date()))), Fiscal_Period_Format.)); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this gives you any trouble, try removing the dot from the format name: &amp;nbsp; ... Fiscal_Period_Format));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 15:23:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Saving-Formatted-Text-to-a-Macro-Variable/m-p/239533#M44080</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-12-16T15:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: Saving Formatted Text to a Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Saving-Formatted-Text-to-a-Macro-Variable/m-p/239573#M44090</link>
      <description>&lt;P&gt;My question would be, why do you need to do this in macro language? &amp;nbsp;There doesn't seem to be any value, and simple Base SAS would do this just fine:&lt;/P&gt;
&lt;PRE&gt;data _null_;
   call symput('currentFiscalPeriod',input(month(date()),fiscal_period_format.);
run;&lt;/PRE&gt;
&lt;P&gt;Saying that, not sure why you need the format either, why does z2. not suffice?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 17:02:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Saving-Formatted-Text-to-a-Macro-Variable/m-p/239573#M44090</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-12-16T17:02:29Z</dc:date>
    </item>
  </channel>
</rss>

