<?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: Get the date from range in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Get-the-date-from-range/m-p/800822#M315099</link>
    <description>&lt;P&gt;The &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/lefunctionsref/p0jshdjy2z9zdzn1h7k90u99lyq6.htm" target="_self"&gt;SAS Docu for the SCAN() Function&lt;/A&gt; will tell you that this function allows for additional parameters of which one is for definition of the characters used as word separators.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_1-1646734829156.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69252i66E0EB33E6A01620/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_1-1646734829156.png" alt="Patrick_1-1646734829156.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile datalines truncover;
  input LB_DOSS $40.;
  Date_prelevement=input(scan(LB_DOSS,-1,' '),ddmmyy10.);
  format date_prelevement date9.;
  datalines;
blbla 21/07/2021
blabla 23/06/2009
;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1646734664173.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69251iD27AF41896CF0F81/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1646734664173.png" alt="Patrick_0-1646734664173.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Mar 2022 22:04:48 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2022-03-08T22:04:48Z</dc:date>
    <item>
      <title>Get the date from range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-date-from-range/m-p/800688#M315028</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My data is&amp;nbsp; LB_DOSS that have the values, for example,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;blbla 21/07/2021&lt;/P&gt;
&lt;P&gt;blabla 23/06/2009&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I extract the data like&amp;nbsp; Date_prelevement=scan(LB_DOSS,-1); My results are :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;21/07/2021&lt;/P&gt;
&lt;P&gt;23/06/2009&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you know please the best way to convert the date (DD/MM/YYYY) from character to numeric values&amp;nbsp; ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help !&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 20:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-date-from-range/m-p/800688#M315028</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2022-03-07T20:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Get the date from range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-date-from-range/m-p/800708#M315035</link>
      <description>&lt;P&gt;Can you please explain how we can find, in general, the date information you want in this character string?&amp;nbsp;Do we find the first space after blablabla and read the date? Can blablabla have its own space in it? Do we have to follow some other rules? If so, what are they? We need to know what rules will work here. We shouldn't have to guess ... you know what the rules are so tell us.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As I said in your other thread, you are strongly advised to present data in an accepted and useful format without us even asking. Do this automatically from now on please. No exceptions, no excuses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;We need to see a portion of data set DOSS2 provided according to&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self" rel="nofollow noopener noreferrer"&gt;these instructions&lt;/A&gt;&lt;SPAN&gt;. Many people just ignore the instructions when I mention it. Please do not provide the data in any other manner, as that won't help, and we'll just ask you to follow the instructions again.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 07 Mar 2022 20:05:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-date-from-range/m-p/800708#M315035</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-03-07T20:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: Get the date from range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-date-from-range/m-p/800725#M315044</link>
      <description>Thank you for your message.&lt;BR /&gt;Sorry, I improved my question.</description>
      <pubDate>Mon, 07 Mar 2022 20:31:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-date-from-range/m-p/800725#M315044</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2022-03-07T20:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Get the date from range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-date-from-range/m-p/800728#M315046</link>
      <description>&lt;P&gt;The INPUT() function let's you use an INFORMAT to convert text into values.&amp;nbsp; So if you use the informat of DDMMYY it will be able to convert those string into date values.&amp;nbsp; You can then assign the values to a numeric variable and attach a format that works with date values to display them in a way that humans will understand.&amp;nbsp; I would avoid using DDMMYY or MMDDYY as the display format as either one will confuse half of your audience.&amp;nbsp; So use DATE or YYMMDD instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  Date_prelevement=input(scan(LB_DOSS,-1),ddmmyy10.);
  format date_prelevement date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Mar 2022 20:45:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-date-from-range/m-p/800728#M315046</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-07T20:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: Get the date from range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-date-from-range/m-p/800818#M315097</link>
      <description>Hello Tom,&lt;BR /&gt;&lt;BR /&gt;Finally, I do : Date_prelevement=scan(LB_DOSS,-3)||"/"||scan(LB_DOSS,-2)||"/"||scan(LB_DOSS,-1)&lt;BR /&gt;because when I do scan(LB_DOSS,-1) I have only the year. Do you know some option for scan function to avoid the "/" and get the date without scanning 3 times please ?&lt;BR /&gt;&lt;BR /&gt;Thank you !</description>
      <pubDate>Tue, 08 Mar 2022 10:10:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-date-from-range/m-p/800818#M315097</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2022-03-08T10:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Get the date from range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-date-from-range/m-p/800822#M315099</link>
      <description>&lt;P&gt;The &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/lefunctionsref/p0jshdjy2z9zdzn1h7k90u99lyq6.htm" target="_self"&gt;SAS Docu for the SCAN() Function&lt;/A&gt; will tell you that this function allows for additional parameters of which one is for definition of the characters used as word separators.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_1-1646734829156.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69252i66E0EB33E6A01620/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_1-1646734829156.png" alt="Patrick_1-1646734829156.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile datalines truncover;
  input LB_DOSS $40.;
  Date_prelevement=input(scan(LB_DOSS,-1,' '),ddmmyy10.);
  format date_prelevement date9.;
  datalines;
blbla 21/07/2021
blabla 23/06/2009
;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1646734664173.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69251iD27AF41896CF0F81/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1646734664173.png" alt="Patrick_0-1646734664173.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 22:04:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-date-from-range/m-p/800822#M315099</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-03-08T22:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: Get the date from range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-date-from-range/m-p/800866#M315121</link>
      <description>Thank you Patrick !</description>
      <pubDate>Tue, 08 Mar 2022 15:19:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-date-from-range/m-p/800866#M315121</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2022-03-08T15:19:49Z</dc:date>
    </item>
  </channel>
</rss>

