<?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: Conditional naming based on time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditional-naming-based-on-time/m-p/636691#M189184</link>
    <description>&lt;P&gt;And to add to others: The time() function starts counting seconds at the beginning of each new day. So for anything that spans over midnight you need to build logic accordingly (not done in below code).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let timenow=;
%let reportname=;
data _null_;
  timenow=time();
  call symputx('timenow',put(timenow,time.));
  if '17:30:00't&amp;lt;=timenow&amp;lt;='17:35:00't then
    call symputx('reportname','LSR2_Down_Report_4');
  else 
  if '20:30:00't&amp;lt;=timenow&amp;lt;='24:35:00't then
    call symputx('reportname','LSR2_Down_Report_6');
  stop;
run;

%put &amp;amp;=timenow;
%put &amp;amp;=reportname;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 01 Apr 2020 22:21:55 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2020-04-01T22:21:55Z</dc:date>
    <item>
      <title>Conditional naming based on time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-naming-based-on-time/m-p/636682#M189179</link>
      <description>&lt;P&gt;data _null_;&lt;BR /&gt;call symput ('timenow',put (time(),time.));&lt;BR /&gt;if &amp;amp;timenow &amp;gt;= 17:30:00 and &amp;amp;timenow &amp;lt; 17:35:00 then &lt;BR /&gt;%let reportname= LSR2_Down_Report_4;else &lt;BR /&gt;if &amp;amp;timenow &amp;gt;= 20:30:00 and &amp;amp;timenow &amp;lt; 24:35:00 then&lt;BR /&gt;%let reportname= LSR2_Down_Report_6;&lt;BR /&gt;run;&lt;BR /&gt;%put &amp;amp;timenow &amp;amp;reportname;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am attempting to assign a reportname based on the time of day.&lt;/P&gt;
&lt;P&gt;When I run the code I get the following error&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;SYMBOLGEN: Macro variable TIMENOW resolves to 17:40:48&lt;BR /&gt;49 if &amp;amp;timenow &amp;gt;= 17:30:00 and &amp;amp;timenow &amp;lt; 17:35:00 then&lt;BR /&gt;SYMBOLGEN: Macro variable TIMENOW resolves to 17:40:48&lt;BR /&gt;NOTE: Line generated by the macro variable "TIMENOW".&lt;BR /&gt;49 17:40:48&lt;BR /&gt;_&lt;BR /&gt;388&lt;BR /&gt;76&lt;BR /&gt;ERROR 388-185: Expecting an arithmetic operator.&lt;/P&gt;
&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2020 21:52:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-naming-based-on-time/m-p/636682#M189179</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2020-04-01T21:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional naming based on time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-naming-based-on-time/m-p/636686#M189180</link>
      <description>&lt;P&gt;First assign timenow&amp;nbsp; to a data step character var.&amp;nbsp; The result of put is a char string.&amp;nbsp; &amp;nbsp;Then you can use call symput to assign it.&amp;nbsp; &amp;nbsp;. YOu also need to use call symput to assign reportname&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2020 22:19:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-naming-based-on-time/m-p/636686#M189180</guid>
      <dc:creator>DavePrinsloo</dc:creator>
      <dc:date>2020-04-01T22:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional naming based on time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-naming-based-on-time/m-p/636688#M189182</link>
      <description>&lt;P&gt;To compare time to a literal time you need to use a value like '17:30:00't and compare the actual time value instead of a character (macro variable as created which has other issues)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;
if '17:30:00't le time() &amp;lt; '17:35:00't then 
   call symputx('reportname','LSR2_Down_Report_4');
else if '20:30:00't le time() &amp;lt; '24:35:00't then 
   call symputx('reportname','LSR2_Down_Report_4');
else  call symputx('reportname','somethingelse');

run;

%put Reportname = "&amp;amp;reportname.";
&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Apr 2020 22:17:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-naming-based-on-time/m-p/636688#M189182</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-01T22:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional naming based on time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-naming-based-on-time/m-p/636691#M189184</link>
      <description>&lt;P&gt;And to add to others: The time() function starts counting seconds at the beginning of each new day. So for anything that spans over midnight you need to build logic accordingly (not done in below code).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let timenow=;
%let reportname=;
data _null_;
  timenow=time();
  call symputx('timenow',put(timenow,time.));
  if '17:30:00't&amp;lt;=timenow&amp;lt;='17:35:00't then
    call symputx('reportname','LSR2_Down_Report_4');
  else 
  if '20:30:00't&amp;lt;=timenow&amp;lt;='24:35:00't then
    call symputx('reportname','LSR2_Down_Report_6');
  stop;
run;

%put &amp;amp;=timenow;
%put &amp;amp;=reportname;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Apr 2020 22:21:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-naming-based-on-time/m-p/636691#M189184</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-04-01T22:21:55Z</dc:date>
    </item>
  </channel>
</rss>

