<?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: How do i create a new date variable using other date variables? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-create-a-new-date-variable-using-other-date-variables/m-p/471540#M285751</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/146852"&gt;@sms1891&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Uniq_ID's can be same or different in each of these data sets, I don't care about them since I am stacking them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you're stacking why do you have the BY statement? I suspect that will not give you the results you want.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Jun 2018 22:06:45 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-06-19T22:06:45Z</dc:date>
    <item>
      <title>How do i create a new date variable using other date variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-create-a-new-date-variable-using-other-date-variables/m-p/471532#M285748</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am trying to create a new data set by stacking 10 different data sets. Each of these data sets have a uniq_ID and a Date variable (eg. Date1 for data1 and date2 for Data2, date3 for data3, etc.). My goal is to create a new variable called Date_Final using Date1, date2, Date3, Dat4, ....Date10. Essentially my new date variable, Date_Final should copy dates from all 10 data sets and create a new column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Final;&lt;/P&gt;&lt;P&gt;Set Data1 Data2 Data3 ....Data10;&lt;/P&gt;&lt;P&gt;by Uniq_ID;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each of these data sets contain the following:&lt;/P&gt;&lt;P&gt;Data1: Uniq_ID and Date1&lt;/P&gt;&lt;P&gt;Data2: Uniq_ID and Date2&lt;/P&gt;&lt;P&gt;Data3: Uniq_ID and Date3&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;Data10: Uniq_ID and Date10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Uniq_ID's can be same or different in each of these data sets, I don't care about them since I am stacking them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Final data set should contain:&lt;/P&gt;&lt;P&gt;Uniq_ID&amp;nbsp;&amp;nbsp;&amp;nbsp; Date_Final&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 21:53:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-create-a-new-date-variable-using-other-date-variables/m-p/471532#M285748</guid>
      <dc:creator>sms1891</dc:creator>
      <dc:date>2018-06-19T21:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do i create a new date variable using other date variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-create-a-new-date-variable-using-other-date-variables/m-p/471538#M285749</link>
      <description>&lt;P&gt;Data Final;&lt;/P&gt;
&lt;P&gt;Set Data1 &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;(rename=date1=date_final) &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Data2 &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;(rename=date2=date_final)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Data3 ....Data10;&lt;/P&gt;
&lt;P&gt;by Uniq_ID;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 22:02:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-create-a-new-date-variable-using-other-date-variables/m-p/471538#M285749</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-19T22:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do i create a new date variable using other date variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-create-a-new-date-variable-using-other-date-variables/m-p/471539#M285750</link>
      <description>&lt;P&gt;if the dates are actually SAS date valued numeric then this should work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date_final= max(of date1 -date10);&lt;/P&gt;
&lt;P&gt;if the ONLY values you want at the end are Uniq_ID&amp;nbsp;&amp;nbsp;&amp;nbsp; Date_Final then use a keep statement:&lt;/P&gt;
&lt;P&gt;keep Uniq_ID&amp;nbsp;&amp;nbsp;&amp;nbsp; Date_Final;&lt;/P&gt;
&lt;P&gt;if there are other variables involved but you want to drop the various date variables then use drop:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;drop date1-date10;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A good idea is not to put "data" into variable names. If you had a&amp;nbsp; single name, "date" for instance, this step would not be needed when appending data with this method.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 22:03:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-create-a-new-date-variable-using-other-date-variables/m-p/471539#M285750</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-19T22:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do i create a new date variable using other date variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-create-a-new-date-variable-using-other-date-variables/m-p/471540#M285751</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/146852"&gt;@sms1891&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Uniq_ID's can be same or different in each of these data sets, I don't care about them since I am stacking them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you're stacking why do you have the BY statement? I suspect that will not give you the results you want.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 22:06:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-create-a-new-date-variable-using-other-date-variables/m-p/471540#M285751</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-19T22:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do i create a new date variable using other date variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-create-a-new-date-variable-using-other-date-variables/m-p/471542#M285752</link>
      <description>&lt;P&gt;You could adopt this approach perhaps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Demo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data w1 w2 w3;
set sashelp.class;
run;


data w1;
set w1;
date1=today();
run;

data w2;
set w2;
date2=today()+1;
run;


data w3;
set w3;
date3=today()+2;
run;

data want;
set w1 w2 w3 indsname=k;
k1=k;
date_final=sum(of date: );
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or&amp;nbsp;&lt;STRONG&gt;date_final=coalesce(of date:&amp;nbsp; )&amp;nbsp; ;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 22:20:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-create-a-new-date-variable-using-other-date-variables/m-p/471542#M285752</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-19T22:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do i create a new date variable using other date variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-create-a-new-date-variable-using-other-date-variables/m-p/471554#M285753</link>
      <description>&lt;P&gt;Ok I will not use the by statement.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 22:48:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-create-a-new-date-variable-using-other-date-variables/m-p/471554#M285753</guid>
      <dc:creator>sms1891</dc:creator>
      <dc:date>2018-06-19T22:48:58Z</dc:date>
    </item>
  </channel>
</rss>

