<?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: Date manupulations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426435#M105060</link>
    <description>&lt;P&gt;if the dates are 2017-01--01&lt;BR /&gt;2011-01--&lt;BR /&gt;I need output as 2017-01-01&lt;BR /&gt;2011-01&lt;/P&gt;&lt;P&gt;In this case we have to keep anycondition to check whether we have day in the given date or not or else we have any format to get the above mentioned output?&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jan 2018 13:30:45 GMT</pubDate>
    <dc:creator>molla</dc:creator>
    <dc:date>2018-01-10T13:30:45Z</dc:date>
    <item>
      <title>Date manupulations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426367#M105034</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have dates like 2017-01--&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;I need my output as 2017-01&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a code without hard coding&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 11:04:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426367#M105034</guid>
      <dc:creator>molla</dc:creator>
      <dc:date>2018-01-10T11:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: Date manupulations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426372#M105037</link>
      <description>&lt;P&gt;So your dates are stored as text or?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 11:16:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426372#M105037</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-01-10T11:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: Date manupulations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426376#M105039</link>
      <description>stored as character&lt;BR /&gt;</description>
      <pubDate>Wed, 10 Jan 2018 11:23:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426376#M105039</guid>
      <dc:creator>molla</dc:creator>
      <dc:date>2018-01-10T11:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Date manupulations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426381#M105042</link>
      <description>&lt;P&gt;Something like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	CharDate="2017-01--";
run;

data want;
	set have;
	NumDate=input(compress(CharDate, "-"), yymmn6.);
	format NumDate yymmn6.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Jan 2018 11:27:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426381#M105042</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-01-10T11:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: Date manupulations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426384#M105043</link>
      <description>&lt;P&gt;Posting test data in the form of a datastep really illustrates problems.&amp;nbsp; From what you post a simple:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  date=substr(date,1,7);
run;&lt;/PRE&gt;
&lt;P&gt;Will work, but I doubt that is your full problem.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 11:30:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426384#M105043</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-10T11:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: Date manupulations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426386#M105044</link>
      <description>The output should be 2017-01</description>
      <pubDate>Wed, 10 Jan 2018 11:43:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426386#M105044</guid>
      <dc:creator>molla</dc:creator>
      <dc:date>2018-01-10T11:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: Date manupulations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426392#M105046</link>
      <description>&lt;P&gt;Then use YYMMd format&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	CharDate="2017-01--";
run;

data want;
	set have;
	NumDate=input(compress(CharDate, "-"), yymmn6.);
	format NumDate YYMMd.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 12:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426392#M105046</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-01-10T12:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: Date manupulations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426435#M105060</link>
      <description>&lt;P&gt;if the dates are 2017-01--01&lt;BR /&gt;2011-01--&lt;BR /&gt;I need output as 2017-01-01&lt;BR /&gt;2011-01&lt;/P&gt;&lt;P&gt;In this case we have to keep anycondition to check whether we have day in the given date or not or else we have any format to get the above mentioned output?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 13:30:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426435#M105060</guid>
      <dc:creator>molla</dc:creator>
      <dc:date>2018-01-10T13:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Date manupulations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426461#M105070</link>
      <description>&lt;P&gt;Please focus your question, by providing the required information so that we don't have to guess which is a waste of your time and ours.&amp;nbsp; Start by:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Posting test data in the form of a datastep which shows the connotations in your data you want to change.&amp;nbsp; If you are unsure on how to do this follow this post (note we just need a few rows which illustrate the issues):&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next up explain what the data processing rules are you want implement, you say for instance that 2017-01--01 should result in 2017-01-01, the question would be why, this is not correct format in any system ever:&amp;nbsp;&lt;SPAN&gt;2017-01--01, so why are you getting data in such a way - sounds like either something broke in a previous system or in previous code.&amp;nbsp; Best to fix it there.&amp;nbsp; What happens for month missing?&amp;nbsp; Is it to be a SAS date variable, or should it be text output?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Finally showing some output as you would expect it is a good idea.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For the --, you could simply tranwrd this:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;date=tranwrd(date,"--","-");&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But I suspect you have more issues than that and fixing it in the first place would be my choice.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;There are ISO date formats and informats you can work with - e8601dt. for instance, but they would be used for numeric dates, so partials would need imputations for missing components.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 14:34:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426461#M105070</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-10T14:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Date manupulations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426511#M105086</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/116130"&gt;@molla&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;if the dates are 2017-01--01&lt;BR /&gt;2011-01--&lt;BR /&gt;I need output as 2017-01-01&lt;BR /&gt;2011-01&lt;/P&gt;
&lt;P&gt;In this case we have to keep anycondition to check whether we have day in the given date or not or else we have any format to get the above mentioned output?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT color="#993366" size="5"&gt;&lt;STRONG&gt;?????&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;The above makes it look like you want to chang years???&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;Provide examples of all of the malformed date-appearing values and what date you want them actually treated as.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;For example are you getting dates that look like &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;&amp;nbsp;-01-30 (missing year)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;2017-27 (missing month)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;2017-- (missing month and day)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;Provide the rules for handling each.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;Note that the examples with input using the yymm formats are implying the day of the month will be 1. If you want a different day of the month then we need explicit rules as to what it should be.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 15:58:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-manupulations/m-p/426511#M105086</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-10T15:58:44Z</dc:date>
    </item>
  </channel>
</rss>

