<?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: struggling with dates in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/struggling-with-dates/m-p/668440#M23123</link>
    <description>&lt;P&gt;Thanks, it has worked!&lt;/P&gt;&lt;P&gt;And how could I ask SAS for this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First, class the dates from older to newer;&lt;/P&gt;&lt;P&gt;if date is before 31-01-2018, then delete this line.&lt;/P&gt;&lt;P&gt;if date is after 31-01-2019 then delete this line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 10 Jul 2020 18:43:58 GMT</pubDate>
    <dc:creator>Annie_Fréchette</dc:creator>
    <dc:date>2020-07-10T18:43:58Z</dc:date>
    <item>
      <title>struggling with dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/struggling-with-dates/m-p/668435#M23119</link>
      <description>&lt;P&gt;Hi! I'm having some issues with a variable. Test_date is , when I double click ont it, a character type. But it's a date. Ex:18-12-2017. I try to convert it in a date format (DDMMYY10.;) but it doesn't work.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.f2sd;
set work.f2sd;
informat Test_date DDMMYY10.;
format Test_date DDMMYY10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here is my log:&lt;/P&gt;&lt;P&gt;326 data work.f2sd;&lt;BR /&gt;327 set work.f2sd;&lt;BR /&gt;328 informat Test_date $DDMMYY10.;&lt;BR /&gt;----------&lt;BR /&gt;48&lt;BR /&gt;ERROR 48-59: Le(la) informat $DDMMYY est introuvable ou n'a pas pu être chargé(e).&lt;/P&gt;&lt;P&gt;329 format Test_date $DDMMYY10.;&lt;BR /&gt;----------&lt;BR /&gt;48&lt;BR /&gt;ERROR 48-59: Le(la) format $DDMMYY est introuvable ou n'a pas pu être chargé(e).&lt;/P&gt;&lt;P&gt;330 run;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.F2SD may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 8 variables.&lt;BR /&gt;WARNING: Table WORK.F2SD non remplacée car cette étape a été interrompue.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.03 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone can help?&lt;/P&gt;&lt;P&gt;And I have a second question: How could I code for this steps:&lt;/P&gt;&lt;P&gt;First, class the dates from older to newer;&lt;/P&gt;&lt;P&gt;if date is before 31-01-2018, then delete this line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 18:19:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/struggling-with-dates/m-p/668435#M23119</guid>
      <dc:creator>Annie_Fréchette</dc:creator>
      <dc:date>2020-07-10T18:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: struggling with dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/struggling-with-dates/m-p/668437#M23121</link>
      <description>&lt;P&gt;An INFORMAT is used when converting text to values. Attaching it to an existing variable does not really do anything if you are not reading values into that variable.&amp;nbsp; And as the error message says your variable is already a character variable so you cannot attach the numeric informat to it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looks like you need to create a new numeric variable from your existing character variable.&amp;nbsp; Here is code to create a new numeric variable named ACTUAL_DATE from your existing character variable TEST_DATE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.f2sd_fixed;
  set work.f2sd;
  actual_date = input(Test_date,DDMMYY10.);
  format actual_date DDMMYY10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Notice how I used a new name for the dataset also.&amp;nbsp; If you use the same name then the original dataset will be deleted when the new dataset is created.&lt;/P&gt;
&lt;P&gt;I did not bother to attach an informat to the new variable since it is of not much use for an existing variable.&amp;nbsp; But I did attach a format so the number of days that are stored in ACTUAL_DATE will be displayed in way that a human could understand.&amp;nbsp; (Personally avoid using DMY or MDY order for dates to avoid people confusing the tenth of December and November twelfth. I always use either DATE or YYMMDD format for dates.)&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 18:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/struggling-with-dates/m-p/668437#M23121</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-10T18:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: struggling with dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/struggling-with-dates/m-p/668438#M23122</link>
      <description>&lt;P&gt;SAS dates are numeric. Since you cannot change the type of a variable, you need to replace it with a newly created variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.f2sd (drop=_td);
set work.f2sd (rename=(test_date=_td));
Test_date = input(_td,ddmmyy10.);
format Test_date DDMMYY10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jul 2020 18:38:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/struggling-with-dates/m-p/668438#M23122</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-10T18:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: struggling with dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/struggling-with-dates/m-p/668440#M23123</link>
      <description>&lt;P&gt;Thanks, it has worked!&lt;/P&gt;&lt;P&gt;And how could I ask SAS for this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First, class the dates from older to newer;&lt;/P&gt;&lt;P&gt;if date is before 31-01-2018, then delete this line.&lt;/P&gt;&lt;P&gt;if date is after 31-01-2019 then delete this line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 18:43:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/struggling-with-dates/m-p/668440#M23123</guid>
      <dc:creator>Annie_Fréchette</dc:creator>
      <dc:date>2020-07-10T18:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: struggling with dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/struggling-with-dates/m-p/668441#M23124</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
where '31jan2018'd le date le '31jan2019'd;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jul 2020 18:48:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/struggling-with-dates/m-p/668441#M23124</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-10T18:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: struggling with dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/struggling-with-dates/m-p/668448#M23125</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/307594"&gt;@Annie_Fréchette&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks, it has worked!&lt;/P&gt;
&lt;P&gt;And how could I ask SAS for this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, class the dates from older to newer;&lt;/P&gt;
&lt;P&gt;if date is before 31-01-2018, then delete this line.&lt;/P&gt;
&lt;P&gt;if date is after 31-01-2019 then delete this line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not sure what you mean by class.&amp;nbsp; You can use PROC SORT to order the observations by the value of date.&amp;nbsp; But many procedures will group, or class, the data without having to first order the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To subset the data you can use a WHERE statement (or in a data step a subsetting IF or IF/THEN/DELETE).&amp;nbsp; To reference a specific date in code you use a quoted string in a style the DATE informat understands suffixed with the letter d.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where actual_date between '31jan2018'd and '31jan2019'd;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jul 2020 19:05:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/struggling-with-dates/m-p/668448#M23125</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-10T19:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: struggling with dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/struggling-with-dates/m-p/668449#M23126</link>
      <description>&lt;P&gt;Thanks! It worked!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 19:09:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/struggling-with-dates/m-p/668449#M23126</guid>
      <dc:creator>Annie_Fréchette</dc:creator>
      <dc:date>2020-07-10T19:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: struggling with dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/struggling-with-dates/m-p/668451#M23127</link>
      <description>&lt;P&gt;Thanks Tom, I just learned two ways of getting my specified dates!:)&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 19:10:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/struggling-with-dates/m-p/668451#M23127</guid>
      <dc:creator>Annie_Fréchette</dc:creator>
      <dc:date>2020-07-10T19:10:24Z</dc:date>
    </item>
  </channel>
</rss>

