<?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: Macro Assignment in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173051#M301740</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To work with functions in macro code you need to learn to use %SYSFUNC() macro function.&lt;/P&gt;&lt;P&gt;If you want to keep your macro variables looking like human readable datetime values then perhaps just add the ""DT to convert them into datetime literals later.&lt;/P&gt;&lt;P&gt;For your particular conversion you can use INTNX() function using the DTYEAR interval and eliminate the extra function calls.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let Start_Date = 06FEB2013:00:00:00;&lt;/P&gt;&lt;P&gt;%let Prev_Begin = %sysfunc(intnx(dtyear,"&amp;amp;start_date"dt,-1,b),datetime19.) ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Jan 2015 18:50:28 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2015-01-07T18:50:28Z</dc:date>
    <item>
      <title>Macro Assignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173040#M301729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry this is a pick up of a previously answered question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I understand how to create and reference a macro, (%let macrovalue / &amp;amp;macrovalue).&lt;/P&gt;&lt;P&gt;However, if I have the results of a function, how does one assign this result to a macro value? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For instance, &lt;/P&gt;&lt;P&gt;Helpful code was provided in my previous query, illustrating how to use INTNX, where variable "prevybeg" was defined as '01JAN2012:0:0:0'dt;&lt;/P&gt;&lt;P&gt;How best would one establish a macro variable using the calculated value of variable "prevybeg"? &lt;/P&gt;&lt;P&gt;Is it best form to just use nested sysfunc's and calculate the macro directly? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let Start_Date = '06FEB2013:0:0:0'dt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;prevybeg=dhms(intnx('year',datepart(&amp;amp;Start_Date),-1,'b'),0,0,0);&lt;/P&gt;&lt;P&gt;format prevybeg datetime19.;&lt;/P&gt;&lt;P&gt;put prevybeg=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2015 16:03:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173040#M301729</guid>
      <dc:creator>GalacticAbacus</dc:creator>
      <dc:date>2015-01-07T16:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Assignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173041#M301730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would use the nested %sysfunc if practical. It would at least let me know when I look at the code later that all I wanted was a single macro variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I might be tempted to test building it in a data step though to check on building the pieces of a complicated expression. If you have the value in a datastep then either CALL SYMPUT or CALL SYMPUTX would the way to create the macro variable with the desired value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And if my times are always 0:0:0 I would seriously consider using Date instead of Datetime values to reduce the number of complicated coding bits. Or at least delay as long as possible the conversion.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2015 16:19:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173041#M301730</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-01-07T16:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Assignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173042#M301731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are a few methods, you could call symput and create a new mvar from that datastep, or you could use eval:&lt;/P&gt;&lt;P&gt;%let mvar=%eval(&amp;amp;mvar. +1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, as I suggested in your other post, mvars are not in my opinion the best method of keeping this type of data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2015 16:19:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173042#M301731</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-01-07T16:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Assignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173043#M301732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks RW9 however I'm attempting to build on my current understanding in order to familiarize myself with syntax and common practice. I realize there are probably numerable more efficient ways however I currently don't know them. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Conceptually, Macro's variables seemed to be a way to store variables with values which could be used to referenced throughout a given process flow. If there is a better way to do this I'm all ears.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2015 16:24:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173043#M301732</guid>
      <dc:creator>GalacticAbacus</dc:creator>
      <dc:date>2015-01-07T16:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Assignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173044#M301733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How you work and what you may need to diagnose program issues is a very valid consideration in this type of style choice. I can definitely see the point of dataset storage if I am running programs in a batch mode and want the persistence of actual values without having to try to wade through lots of log type output to examine possible values. You may also need to provide audit trails for such things in some environments.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2015 16:32:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173044#M301733</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-01-07T16:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Assignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173045#M301734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Would you mind checking my attempt below? Is this a correct use of sysfunc? &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;prevybeg=dhms(intnx('year',datepart(&amp;amp;Start_Date),-1,'b'),0,0,0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%let prevybeg = %sysfunc(dhms(%sysfunc(intnx('year',datepart(&amp;amp;Start_Date),-1,'b'),0,0,0));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;TS&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2015 16:41:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173045#M301734</guid>
      <dc:creator>GalacticAbacus</dc:creator>
      <dc:date>2015-01-07T16:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Assignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173046#M301735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;datepart is also a function and needs a sysfunc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When passing text parameters/modifiers to a function in a macro the quotes are removed, i.e. year and b shouldn't have quotes&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2015 17:07:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173046#M301735</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-01-07T17:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Assignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173047#M301736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%let prevybeg = %sysfunc(dhms(%sysfunc(intnx(year,%sysfunc(datepart(&amp;amp;Start_Date),-1,b),0,0,0))));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2015 17:52:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173047#M301736</guid>
      <dc:creator>GalacticAbacus</dc:creator>
      <dc:date>2015-01-07T17:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Assignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173048#M301737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try it &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Make sure to note what format your macro variable is in and what type the function requires.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2015 17:56:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173048#M301737</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-01-07T17:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Assignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173049#M301738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh sorry I should have specified, I did try it and it did not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2015 18:00:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173049#M301738</guid>
      <dc:creator>GalacticAbacus</dc:creator>
      <dc:date>2015-01-07T18:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Assignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173050#M301739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%let Start_Date =06FEB2013:0:0:0;&lt;/P&gt;&lt;P&gt;%let prevybeg =%sysfunc(putn(%sysfunc(dhms(%sysfunc(intnx(year,%sysfunc(datepart("&amp;amp;Start_Date"dt)),-1,b)),0,0,0)),datetime19.));&lt;/P&gt;&lt;P&gt;%put &amp;amp;prevybeg;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2015 18:48:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173050#M301739</guid>
      <dc:creator>slchen</dc:creator>
      <dc:date>2015-01-07T18:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Assignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173051#M301740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To work with functions in macro code you need to learn to use %SYSFUNC() macro function.&lt;/P&gt;&lt;P&gt;If you want to keep your macro variables looking like human readable datetime values then perhaps just add the ""DT to convert them into datetime literals later.&lt;/P&gt;&lt;P&gt;For your particular conversion you can use INTNX() function using the DTYEAR interval and eliminate the extra function calls.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let Start_Date = 06FEB2013:00:00:00;&lt;/P&gt;&lt;P&gt;%let Prev_Begin = %sysfunc(intnx(dtyear,"&amp;amp;start_date"dt,-1,b),datetime19.) ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2015 18:50:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Assignment/m-p/173051#M301740</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-01-07T18:50:28Z</dc:date>
    </item>
  </channel>
</rss>

