<?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 call symput() in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/171058#M32839</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, expert&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Most of the time when I come to CALL SMPUT() in daily programming work, I always get unexpected macro errors.&amp;nbsp; Please help to correct me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I always need to set a macro to store the exact days of certain month in financial report and retrieve them in data steps.&amp;nbsp; But the newly created variables yy, mm and dd&amp;nbsp; are all in 20178 (ie 2015-3-31), not 2015-3-1, 2015-3-2....... and 2015-3-31 as I expect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;e.g.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%macro report;&lt;BR /&gt;&amp;nbsp; data report;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do loop=mdy(3,1,2015) to mdy(3,31,2015);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;call symput("x",loop);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* where &amp;amp;x in dates need to be referred in later part */;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;xx=&amp;amp;x;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cyear=year(&amp;amp;x);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmonth=month(&amp;amp;x);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cdate=day(&amp;amp;x);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; run;&lt;BR /&gt;%mend report;&lt;/P&gt;&lt;P&gt;%report;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;jones&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Jul 2014 15:56:20 GMT</pubDate>
    <dc:creator>JonesSmith</dc:creator>
    <dc:date>2014-07-08T15:56:20Z</dc:date>
    <item>
      <title>call symput()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/171058#M32839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, expert&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Most of the time when I come to CALL SMPUT() in daily programming work, I always get unexpected macro errors.&amp;nbsp; Please help to correct me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I always need to set a macro to store the exact days of certain month in financial report and retrieve them in data steps.&amp;nbsp; But the newly created variables yy, mm and dd&amp;nbsp; are all in 20178 (ie 2015-3-31), not 2015-3-1, 2015-3-2....... and 2015-3-31 as I expect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;e.g.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%macro report;&lt;BR /&gt;&amp;nbsp; data report;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do loop=mdy(3,1,2015) to mdy(3,31,2015);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;call symput("x",loop);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* where &amp;amp;x in dates need to be referred in later part */;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;xx=&amp;amp;x;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cyear=year(&amp;amp;x);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmonth=month(&amp;amp;x);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cdate=day(&amp;amp;x);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; run;&lt;BR /&gt;%mend report;&lt;/P&gt;&lt;P&gt;%report;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;jones&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 15:56:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/171058#M32839</guid>
      <dc:creator>JonesSmith</dc:creator>
      <dc:date>2014-07-08T15:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: call symput()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/171059#M32840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is the correct behaviour. SAS stored dates as numbers, where 1 is Jan 1, 1960 and 2 is Jan 2, 1960 and so forth.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want a specified display format you need to apply a format. Note that it will have leading zeros, ie 04 and 01 in month/day values &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;For a year month day format, such as 2014-04-01 use &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;call symput("x",put(loop, yymmddd10.);&amp;nbsp; &lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 16:33:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/171059#M32840</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-07-08T16:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: call symput()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/171060#M32841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; In SAS dates, 0 is January 1, 1960 and 1 is January 2, 1960 and -1 is Dec 31, 1959. You can run this program to see that 0 is Jan 1, 1960.&lt;/P&gt;&lt;P&gt;Cynthia&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;data whatdate;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; infile datalines;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; input thedate;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; put "Internal value " thedate= 'Now formatted: ' thedate= mmddyy10.;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;return;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;-1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;-2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;-3334&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;18439&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;19912&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 16:43:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/171060#M32841</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2014-07-08T16:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: call symput()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/171061#M32842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the correction!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 16:46:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/171061#M32842</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-07-08T16:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: call symput()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/171062#M32843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;jones&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jul 2014 01:17:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/171062#M32843</guid>
      <dc:creator>JonesSmith</dc:creator>
      <dc:date>2014-07-09T01:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: call symput()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/171063#M32844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe that error be generated by blank in macro variable. Try call symput&lt;STRONG&gt;X&lt;/STRONG&gt;() .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jul 2014 13:17:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/171063#M32844</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-07-09T13:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: call symput()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/171064#M32845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not sure on the point of your macro.&amp;nbsp; You are going to hit problems as you are generating a macro variable with a datastep loop.&amp;nbsp; So the macro pre-processor gets your code, it does a search and replace on the &amp;amp;x. and finds nothing delclared for X so it throws an error, it never gets to the stage where the datastep is actually run to create X. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your example X always referencing the last mdy, this is because the loop goes over each time and only the last iteration sets the date. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So first question, what is it your trying to achieve?&amp;nbsp; Is it to find all dates within that range and use them to select data, if so then store to dataset and use this in your code, e.g.:&lt;/P&gt;&lt;P&gt;data dates;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attrib mydate format=date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do loop=mdy(3,1,2015) to mdy(3,31,2015);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mydate=loop;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*later on */&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table DATA_TO_WORK_ON as&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATA_I_HAVE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATE in (select MYDATE from WORK.DATES);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jul 2014 14:37:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/171064#M32845</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-07-09T14:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: call symput()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/171065#M32846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's great !&amp;nbsp; Thank you all of you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jul 2014 23:34:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/171065#M32846</guid>
      <dc:creator>JonesSmith</dc:creator>
      <dc:date>2014-07-09T23:34:02Z</dc:date>
    </item>
  </channel>
</rss>

