<?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: update incorrect yesteraday'date column based on today's date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/update-incorrect-yesteraday-date-column-based-on-today-s-date/m-p/631845#M187239</link>
    <description>&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;,it is setting whole table but i need to update single column.i tried below option and it is working thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
update t
set ydate= tdate-1 where ydate&amp;lt;&amp;gt; tdate-1
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 13 Mar 2020 13:14:11 GMT</pubDate>
    <dc:creator>JJP1</dc:creator>
    <dc:date>2020-03-13T13:14:11Z</dc:date>
    <item>
      <title>update incorrect yesteraday'date column based on today's date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-incorrect-yesteraday-date-column-based-on-today-s-date/m-p/631831#M187231</link>
      <description>&lt;P&gt;sample input code&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t;
input name $2. ydate :date9. tdate :date9.;
format ydate tdate date9.;
datalines;
jj 12MAR2020 13MAR2020
kk 15FEB2019 13MAR2020
rr 14FEB2020 15FEB2020
yy 21DEC2010 13MAR2019
;


run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;need to update only the ydate column with expression as (tdate-1)only if ydate is not equal&amp;nbsp; to (tdate-1) and need sample output data as below.please suggest&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;jj 12MAR2020 13MAR2020
kk 12MAR2019 13MAR2020
rr 14FEB2020 15FEB2020
yy 12MAR2019 13MAR2019&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 12:34:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-incorrect-yesteraday-date-column-based-on-today-s-date/m-p/631831#M187231</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2020-03-13T12:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: update incorrect yesteraday'date column based on today's date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-incorrect-yesteraday-date-column-based-on-today-s-date/m-p/631835#M187233</link>
      <description>&lt;P&gt;Why is the year 2019 in the second row?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 12:55:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-incorrect-yesteraday-date-column-based-on-today-s-date/m-p/631835#M187233</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-03-13T12:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: update incorrect yesteraday'date column based on today's date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-incorrect-yesteraday-date-column-based-on-today-s-date/m-p/631840#M187238</link>
      <description>&lt;P&gt;"set to tdate -1 if it's not tdate - 1" is equivalent to "set to tdate - 1", period.&lt;/P&gt;
&lt;P&gt;So you only have to execute&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ydate = tdate - 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;See this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t;
input name $2. ydate :date9. tdate :date9.;
format ydate tdate date9.;
datalines;
jj 12MAR2020 13MAR2020
kk 15FEB2019 13MAR2020
rr 14FEB2020 15FEB2020
yy 21DEC2010 13MAR2019
;

data want;
set t;
ydate = tdate - 1;
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;name	ydate   	tdate
jj	12MAR2020	13MAR2020
kk	12MAR2020	13MAR2020
rr	14FEB2020	15FEB2020
yy	12MAR2019	13MAR2019
&lt;/PRE&gt;
&lt;P&gt;matches what you posted, with the exception of the 2019 typo.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 13:08:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-incorrect-yesteraday-date-column-based-on-today-s-date/m-p/631840#M187238</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-13T13:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: update incorrect yesteraday'date column based on today's date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-incorrect-yesteraday-date-column-based-on-today-s-date/m-p/631845#M187239</link>
      <description>&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;,it is setting whole table but i need to update single column.i tried below option and it is working thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
update t
set ydate= tdate-1 where ydate&amp;lt;&amp;gt; tdate-1
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Mar 2020 13:14:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-incorrect-yesteraday-date-column-based-on-today-s-date/m-p/631845#M187239</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2020-03-13T13:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: update incorrect yesteraday'date column based on today's date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-incorrect-yesteraday-date-column-based-on-today-s-date/m-p/631859#M187244</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256123"&gt;@JJP1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;,it is setting whole table but i need to update single column.i tried below option and it is working thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
update t
set ydate= tdate-1 where ydate&amp;lt;&amp;gt; tdate-1
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;which is an inefficient solution.&lt;/P&gt;
&lt;P&gt;See this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
do i = 1 to 1000000;
  tdate = rand('integer','01jan2000'd,today());
  if mod(i,3) = 0
  then ydate = tdate - 1;
  else ydate = rand('integer','01jan2000'd,today());
  output;
end;
format tdate ydate yymmddd10.;
run;

data want1;
set have;
ydate = tdate - 1;
run;

proc sql;
update have
set ydate = tdate - 1 where ydate &amp;lt;&amp;gt; tdate - 1
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and this log from it:&lt;/P&gt;
&lt;PRE&gt;73         data have;
 74         do i = 1 to 1000000;
 75           tdate = rand('integer','01jan2000'd,today());
 76           if mod(i,3) = 0
 77           then ydate = tdate - 1;
 78           else ydate = rand('integer','01jan2000'd,today());
 79           output;
 80         end;
 81         format tdate ydate yymmddd10.;
 82         run;
 
 NOTE: The data set WORK.HAVE has 1000000 observations and 3 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           2.75 seconds
       cpu time            2.74 seconds
       
 
 83         
 84         data want;
 85         set have;
 86         ydate = tdate - 1;
 87         run;
 
 NOTE: There were 1000000 observations read from the data set WORK.HAVE.
 NOTE: The data set WORK.WANT1 has 1000000 observations and 3 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.22 seconds
       cpu time            0.23 seconds
       
 
 88         
 89         proc sql;
 90         update have
 91         set ydate = tdate - 1 where ydate &amp;lt;&amp;gt; tdate - 1
 92         ;
 NOTE: Der Operator "&amp;lt;&amp;gt;" wird als "not equals" interpretiert.
 NOTE: 666568 rows were updated in WORK.HAVE.
 
 93         quit;
 NOTE:  Verwendet wurde: PROZEDUR SQL - (Gesamtverarbeitungszeit):
       real time           6.37 seconds
       cpu time            6.35 seconds
&lt;/PRE&gt;
&lt;P&gt;As you can see, the data step performs better by at least an order of magnitude. The result is the same, of course.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 13:44:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-incorrect-yesteraday-date-column-based-on-today-s-date/m-p/631859#M187244</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-13T13:44:39Z</dc:date>
    </item>
  </channel>
</rss>

