<?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: End of the month for a different time zone in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/End-of-the-month-for-a-different-time-zone/m-p/529062#M144492</link>
    <description>&lt;P&gt;Important rule: do not format your dates or datetimes to be human readable when writing macro code. The only time they need to be formatted for human readability is when you are either inputting the date/datetime or outputting the date/datetime.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Let T = %sysfunc(tzoneu2s(%sysfunc(tzones2u(%sysfunc(datetime()))),america/los_angeles));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, please don't show us your SASLOG as a (hard-to-read) screen capture. SAS LOG ought to copied as text and pasted into the window that appears when you click on the {i} icon.&lt;/P&gt;</description>
    <pubDate>Tue, 22 Jan 2019 14:52:50 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-01-22T14:52:50Z</dc:date>
    <item>
      <title>End of the month for a different time zone</title>
      <link>https://communities.sas.com/t5/SAS-Programming/End-of-the-month-for-a-different-time-zone/m-p/529049#M144485</link>
      <description>&lt;P&gt;All,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Here is a question that I am struggling with. I would like to find the last day of the month in a different time zone. I know there are countless examples using intnx() which show how to compute the last day of the month. I tried to apply the same concept as shown in one such example. Here is my code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*%Let T = %sysfunc(tzoneu2s(%sysfunc(tzones2u(%sysfunc(datetime()))),asia/singapore));
%Put Test:  &amp;amp;T;
%Let T1 = %sysfunc(intnx('dtmonth', &amp;amp;T, 0, 'E'));
%Put Test1: &amp;amp;T1;*/&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I receive a warning which says:&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasWarning"&gt;WARNING: Argument 1 to function INTNX referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;to a missing value.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;Alternatively, if I format "T" as a date time as shown below, that results in an errror:&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Let T = %sysfunc(tzoneu2s(%sysfunc(tzones2u(%sysfunc(datetime()))),asia/singapore),datetime.);
%Put Test:  &amp;amp;T;
%Let T1 = %sysfunc(intnx('dtmonth', &amp;amp;T, 0, 'E'));
%Put Test1: &amp;amp;T1;&lt;/CODE&gt;&lt;/PRE&gt;&lt;DIV class="sasError"&gt;ERROR: Argument 2 to function INTNX referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list. Execution of %SYSCALL statement or %SYSFUNC&lt;/DIV&gt;&lt;DIV class="sasError"&gt;or %QSYSFUNC function reference is terminated.&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;Any help or advice is appreciated. Thanks in advance.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Best&amp;nbsp;&lt;BR /&gt;Uday&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 14:27:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/End-of-the-month-for-a-different-time-zone/m-p/529049#M144485</guid>
      <dc:creator>UdayGuntupalli</dc:creator>
      <dc:date>2019-01-22T14:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: End of the month for a different time zone</title>
      <link>https://communities.sas.com/t5/SAS-Programming/End-of-the-month-for-a-different-time-zone/m-p/529055#M144487</link>
      <description>&lt;P&gt;Do not use quotes inside of %sysfunc&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Let T1 = %sysfunc(intnx(dtmonth, &amp;amp;T, 0, E));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Jan 2019 14:44:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/End-of-the-month-for-a-different-time-zone/m-p/529055#M144487</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-01-22T14:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: End of the month for a different time zone</title>
      <link>https://communities.sas.com/t5/SAS-Programming/End-of-the-month-for-a-different-time-zone/m-p/529060#M144490</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;,&lt;BR /&gt;&amp;nbsp; Thank you for your response. I updated the code according to your suggestion and still receive the same error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Let T = %sysfunc(tzoneu2s(%sysfunc(tzones2u(%sysfunc(datetime()))),america/los_angeles),datetime.);
%Put Test:  &amp;amp;T;
%Let T1 = %sysfunc(intnx(dtmonth, &amp;amp;T, 0, E));
%Put Test1: &amp;amp;T1;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26426iA0F11AC92856724D/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 14:49:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/End-of-the-month-for-a-different-time-zone/m-p/529060#M144490</guid>
      <dc:creator>UdayGuntupalli</dc:creator>
      <dc:date>2019-01-22T14:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: End of the month for a different time zone</title>
      <link>https://communities.sas.com/t5/SAS-Programming/End-of-the-month-for-a-different-time-zone/m-p/529062#M144492</link>
      <description>&lt;P&gt;Important rule: do not format your dates or datetimes to be human readable when writing macro code. The only time they need to be formatted for human readability is when you are either inputting the date/datetime or outputting the date/datetime.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Let T = %sysfunc(tzoneu2s(%sysfunc(tzones2u(%sysfunc(datetime()))),america/los_angeles));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, please don't show us your SASLOG as a (hard-to-read) screen capture. SAS LOG ought to copied as text and pasted into the window that appears when you click on the {i} icon.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 14:52:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/End-of-the-month-for-a-different-time-zone/m-p/529062#M144492</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-01-22T14:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: End of the month for a different time zone</title>
      <link>https://communities.sas.com/t5/SAS-Programming/End-of-the-month-for-a-different-time-zone/m-p/529065#M144493</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Apart from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;suggestion, you need to tell SAS that your are giving datetime vaues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%Let T = %sysfunc(tzoneu2s(%sysfunc(tzones2u(%sysfunc(datetime()))),asia/singapore),datetime.);
%Put Test:  &amp;amp;T;
/* You need to tell SAS that its a datetime value ("datetime value"dt)*/
/* Since the macro variable T has a value in date time */
%Let T1 = %sysfunc(intnx(dtmonth, "&amp;amp;T"dt, 0, E));
%Put Test1: &amp;amp;T1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Another approache, leave them as SAS numeric date values and avoid giving the format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* In this example the macro varible simply holds numeric value, no format */

%Let T = %sysfunc(tzoneu2s(%sysfunc(tzones2u(%sysfunc(datetime()))),asia/singapore));
%Put Test:  &amp;amp;T;
%Let T1 = %sysfunc(intnx(dtmonth,&amp;amp;T, 0, E));
%Put Test1: &amp;amp;T1;
/* Note: T1 is a numeric value that represent SAS Date, you may later need to apply format to it*/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Jan 2019 14:57:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/End-of-the-month-for-a-different-time-zone/m-p/529065#M144493</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2019-01-22T14:57:45Z</dc:date>
    </item>
  </channel>
</rss>

