<?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: weekday &amp;amp; today functions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/weekday-amp-today-functions/m-p/794978#M254963</link>
    <description>&lt;P&gt;Sounds like you want to extract some specific process dates, rather than set the process date (which is what your code does). Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA final_data;                                                     
    SET transactions;                                                
  if weekday(today())= 2 then if process_date=today()-3;             
  else if weekday(today())= 3 then if process_date=today()-4;        
  else if weekday(today()) in (4,5,6) then if process_date=today()-2;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Looks almost the same, but I changed the assignments to subsetting IFs.&lt;/P&gt;</description>
    <pubDate>Tue, 08 Feb 2022 13:15:03 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2022-02-08T13:15:03Z</dc:date>
    <item>
      <title>weekday &amp; today functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/weekday-amp-today-functions/m-p/794971#M254959</link>
      <description>&lt;P&gt;Hi, i need help in extracting data as per below code..as an example,if weekday(today())= 3 then i need the code to return the process_date = today()-4 meaning i need transactions with only process_date=04FEB2022&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once again if weekday(today()) = 2 then i need the code to return process_date=today()-3 meaning i will need only transactions with process_date=03FEB2022&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See below data have , as well as my code attempt but i do not get desired results&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data transactions;
input process_date :yymmdd10. amount reference &amp;amp;:$50.;
format process_date date9.;
datalines;
2022-02-04 100 trn01
2022-02-04 200 trn02
2022-02-03 300 trn03
2022-02-02 400 trn04
2021-02-01 500 trn05
;

DATA final_data;
    SET transactions;
	 if weekday(today())= 2 then process_date=today()-3;
	 else if weekday(today())= 3 then process_date=today()-4;
	 else if weekday(today()) in (4,5,6) then process_date=today()-2;
RUN;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 12:59:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/weekday-amp-today-functions/m-p/794971#M254959</guid>
      <dc:creator>Solly7</dc:creator>
      <dc:date>2022-02-08T12:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: weekday &amp; today functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/weekday-amp-today-functions/m-p/794972#M254960</link>
      <description>&lt;P&gt;What is incorrect about the output? If you run it today (Tuesday, February 8, 2022) then weekday(today()) gives a value of 3 and so all of your output should have process_date as today()-4, and that's exactly what happens, the resulting process_date is February 4, 2022.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 13:04:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/weekday-amp-today-functions/m-p/794972#M254960</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-08T13:04:16Z</dc:date>
    </item>
    <item>
      <title>Re: weekday &amp; today functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/weekday-amp-today-functions/m-p/794975#M254961</link>
      <description>Hi I get the below results after running my code,which is incorrect &lt;BR /&gt;process_date	amount	reference&lt;BR /&gt;04FEB2022	100	         trn01&lt;BR /&gt;04FEB2022	200	         trn02&lt;BR /&gt;04FEB2022	300	         trn03&lt;BR /&gt;04FEB2022	400	         trn04&lt;BR /&gt;04FEB2022	500	         trn05&lt;BR /&gt;&lt;BR /&gt;                               Data Want&lt;BR /&gt;process_date	amount	reference&lt;BR /&gt;04FEB2022	100	         trn01&lt;BR /&gt;04FEB2022	200	         trn02</description>
      <pubDate>Tue, 08 Feb 2022 13:07:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/weekday-amp-today-functions/m-p/794975#M254961</guid>
      <dc:creator>Solly7</dc:creator>
      <dc:date>2022-02-08T13:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: weekday &amp; today functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/weekday-amp-today-functions/m-p/794978#M254963</link>
      <description>&lt;P&gt;Sounds like you want to extract some specific process dates, rather than set the process date (which is what your code does). Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA final_data;                                                     
    SET transactions;                                                
  if weekday(today())= 2 then if process_date=today()-3;             
  else if weekday(today())= 3 then if process_date=today()-4;        
  else if weekday(today()) in (4,5,6) then if process_date=today()-2;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Looks almost the same, but I changed the assignments to subsetting IFs.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 13:15:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/weekday-amp-today-functions/m-p/794978#M254963</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2022-02-08T13:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: weekday &amp; today functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/weekday-amp-today-functions/m-p/794981#M254965</link>
      <description>Hi Lassen, you have saved my life, your solutions works perfectly fine! I super appreaciate it</description>
      <pubDate>Tue, 08 Feb 2022 13:30:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/weekday-amp-today-functions/m-p/794981#M254965</guid>
      <dc:creator>Solly7</dc:creator>
      <dc:date>2022-02-08T13:30:19Z</dc:date>
    </item>
  </channel>
</rss>

